- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 03:05 AM
Hi Everyone ,
When we are importing data into user table through data source .
Currently when "Active" field is not filled in the excel sheet for a record , the value in the active field is populated a "False" for that record. During new record creation , ensure that default value of active field is taken as "True".
For this i have written code in 2 way as below and both are on before transform and not working.
option1 : not working
{
if (action=='insert'){
target.active =true;
}
option2 : not working
{
if (action=='insert'){
var gr=new GlideRecord('sys_user');
gr.addQuery('user_name',source.u_user_id);
gr.query();
if(gr.next()){
gr.active =true;
gr.update();
}
Kindly help me on this .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 03:44 AM
please share your complete field mapping screenshot, transform map screenshot and transform script screenshot
this should work in onBefore transform script
{
if (action=='insert'){
target.active =true;
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 03:24 AM
Not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 03:20 AM
Hi @Devi D
You can write onBefore transform map event script,
if (action == 'insert') {
target.active = true;
}
If my answer helful and related to the question asked. Please mark it as correct and helpful.
Thank you,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 03:23 AM
I have already tried this and not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 03:44 AM
please share your complete field mapping screenshot, transform map screenshot and transform script screenshot
this should work in onBefore transform script
{
if (action=='insert'){
target.active =true;
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 04:42 AM