Fix script giving an unexpected result
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2024 11:19 PM
Hi All,
Before I had run the following script on alphabet field where the requirement was when I select others in alphabet field the existing value should populate on other alphabet field.
var grTable = new GlideRecord('table_name'); grTable.addEncodedQuery('filter');//use the filter in list view and copy the query. grTable.query(); while (grTable.next()) { if (grTable.caste_field) { grTable.other_caste = grTable.caste_field; grTable.update(); } }
It was working fine but few days back I notice the mentioned fields are full of with value as others instead of the existing value. Till now I am not able to find out how it is happened .
Is it possible to get previous record as it was before or any other solution to get the expected result ?
For more info also refer to :- Solved: populate exiting data in other field and keep cast... - ServiceNow Community
Thank YOU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2024 11:31 PM
Hello @1_DipikaD
I also faced same issue and I used getValue()
var grTable = new GlideRecord('table_name');
grTable.addEncodedQuery('filter');//use the filter in list view and copy the query.
grTable.query();
while (grTable.next()) {
if (grTable.caste_field) {
grTable.other_caste = grTable.getValue('caste_field');
grTable.update();
}
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 12:23 AM
Will it get previous record as it was before ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2024 11:37 PM - edited 10-13-2024 11:37 PM
Hi @1_DipikaD
--> To get previous record as it was before
If it was achieved using a background script.
Yes, it is possible.
Go to the left navigator and search for "Script Execution History."
Find the relevant entry.
In the Related Links, click Rollback Script Execution.
-->
you can use getValue() or toString()
Thanks
Eshwar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 03:59 AM - edited 10-14-2024 04:04 AM
I had tried to rollback but they are got expired . Also I tried above methods still haven't get any result . I don't have backup as well . It's working fine on QA and UAT but in DEV it's not working as expected. Is there any possibility in upcoming days in QA and UAT also it will behave like DEV ?