- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2020 01:42 AM
Hi Team,
I have a requirement where i need to copy my Risk assessment response to my Risk forms. But i am not able to assign values.
Here is my code snippet:
var getResult = new GlideRecord('asmt_metric_result');
getResult.addEncodedQuery('source_id=' + current.sys_id);
getResult.addNotNullQuery('string_value');
getResult.query();
if (getResult.next()) {
var getRisk = new GlideRecord('sn_risk_risk');
getRisk.get(current.sys_id);
var currentFieldNames = [];
for (var f in getRisk) currentFieldNames.push(f);
for (var i = 0; i < currentFieldNames.length; i++) {
if (currentFieldNames[i] == getResult.metric.name) {
getRisk.currentFieldNames[i].setDisplayValue(getResult.string_value);
getRisk.update();
}
}
}
How can i set risk field to the value of the response?
PS: the backend value of question and risk field is same.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2020 02:24 AM
Hi,
please try this and let me know if it works
if (currentFieldNames[i] == getResult.metric.name) {
getRisk[currentFieldNames[i]].setDisplayValue(getResult.string_value);
getRisk.update();
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2020 02:24 AM
Hi,
please try this and let me know if it works
if (currentFieldNames[i] == getResult.metric.name) {
getRisk[currentFieldNames[i]].setDisplayValue(getResult.string_value);
getRisk.update();
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2020 02:29 AM
Thank you so much Ankur. It worked.
How can i miss on this 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2020 02:30 AM
Glad that it helped.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader