- 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:13 AM
Hello @Devi D ,
The alternative would be to make the field by Default Active to true and once the upload is completed make default as false.
If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2025 03:25 AM
As per requirement by default it should be "False"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2025 03:27 AM
Can you try by gr.setValue('active','true');
Using the Single quotes.
Or just right a business rule, when ever a user is created, make Active = true.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2025 03:15 AM
Hi @Devi D
Can you try with below script in Before transform Script -
if (action == 'insert') {
if (!source.active) {
target.active = true;
}
}