How to rename groups ? what is the best practices? and what pre checks needs to be done?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 12:13 AM
Hi All,
We got a requirement to rename 4000 groups.
We have tried via transform map , and it is not working as expected ( empty records are creating , run the transform map using 20 records , 20 empty records got created in lower environment)
Proposed solution :
we have imported all data into a import set table via load data module
--> all the data dump is available in import set table
var gr=new GlideRecord('sys_user_group');
gr.addEncodedQuery('3k records list from group table,');
gr.query();
gs.log(gr.getRowCount());
while(gr.next())
{
var gr1=new GlideRecord('u_group_rename_one_test_import _table');
gr1.addQuery('u_exisitng_group_name',gr.name);
gr1.query();
if(gr1.next())
{
gs.log('i am from if loop');
gr.name=gr1.u_proposed_group_name;
gr.setWorkflow(false);
gr.autoSysFields(false);
gr.update();
}
}
tested by running above script in lower environments , and its working
can we run the same code in PROD? what are pre sanity checks we need to perform before running the script in PROD.
Please provide your inputs , many thanks in advance.
Thank you,
Shabbir Shaik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 03:04 AM - edited 09-11-2023 03:05 AM
I'm a bit confused in what you're doing.
In transform map you can just set name as coalesce. Then in a onbefore script you can set
if (action == 'insert')
ignore = true;
}
At this point you can set target.name == source.u_proposed_group_name
I didn't test this but basically it should work. The run order should be Coalesce fields first and then onBefore script.
This way if there's no match for name as coalesce, then the action will be insert. Your rulecan just ignore that.
Otherwise you can set the name to the proposed value.
So the whole onBefore rule could be
if (action == 'insert')
ignore = true;
}else{
target.name == source.u_proposed_group_name;
}
And then in the transform maps "Field Maps" you'll set Source field as u_exisitng_group_name and Target field as name and set coalesce true.
btw. is it really u_exisitng_group_name or should it be u_existing_group_name?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 03:10 AM
Hi @shabbir5 ,
There can be lot of direct impact in terms of changing Group names.
1. Recommend to update the groups via AD why its done manually ?
2. Groups used in workflows,business rule, properties and rules, they will have direct impact.
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....