- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Using fix script same table we need to copy from one field to other field i tried with below code but it's not working let me know my mistake
var ga=new GlideRecord('sn_compliance_policy_exception');
ga.addEncodedQuery('policy=87420b0bc3ef71103cbbfb1f0501317b^cmdb_ciISEMPTY');
ga.query();
while(ga.next()){
ga.cmdb_ci=ga.user_input;
//current.name = current.u_imei_string;
ga.update();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi, you didn't change anything in the script I gave you right ?
For me it works fine, the record comes up in the cmdb_ci field correctly. Also one thing, you are sure right that the input provided in the user_input field is the name of the cmdb_ci item ? if the name doesn't match then the cmdb_ci wont get populated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @mani55 ,
Maybe try with below code
var ga = new GlideRecord('sn_compliance_policy_exception');
ga.addEncodedQuery('policy=87420b0bc3ef71103cbbfb1f0501317b^cmdb_ciISEMPTY');
ga.query();
while (ga.next()) {
ga.setValue('cmdb_ci', ga.getValue('user_input'));
ga.update();
}
Please mark my answer correct and helpful if this works for you
Thanks and Regards,
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @mani55 ,
Firstly let me know whether you want the field value of cmdb_ci to go to user_input or you want the other way round.
If you want the cmdb_ci value to flow to user_input , replace your 5th line with the below line:
ga.user_input = ga.cmdb_ci.getDisplayValue();I've already tried this in my instance, and it works.
*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @mani55, if the above script from @Sarthak Kashyap will not work (but I hope it will work) - try this one,
var ci = new GlideRecord('cmdb_ci');
ci.addQuery('name', gr.getValue('user_input'));
ci.query();
if (ci.next()) {
gr.setValue('cmdb_ci', ci.getUniqueValue());
gr.update();
}
I hope it helps, and if it was helpful, please vote with thumbs-up, thanks.
Best regards,
Renat Akhmedov
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi
User input field is string field but cmdb_ci field is reference field so we can get copy from that