- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2018 06:42 AM
Hi,
I am storing object specific characteristics in the Name-Value pair field dynamically in ServiceNow table. One record may ave 2 Chars, another may have 5 Chars.
In case of update call from external system, if it is sending us only the updated characteristic from the available 5 for example, how do we query and find out the one that needs to be updated?
E.g. Record ObjectA has one NV pair field which has 3 NV pairs store like below,
Speed 10MBPS
TrafficClass T1
ContractTerm 36M
Now external system is sending the update call with updated characteristic Speed == 20 MBPS.
Kindly suggest how do I handle this scenario? how can I query NV pair to update just one.
Gone through -
https://docs.servicenow.com/bundle/kingston-platform-administration/page/administer/field-administration/reference/name-value-pair-scripting.html
Thanks,
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2018 08:44 AM
In GlideRecord you can just update the value, by passing the name and value on the element.
If it exits, the value will update, if not, the name value pair is added.
var gr = new GlideRecord('incident');
if (gr.get('b9a633db4f1a930035e0fdb28110c728')) {
gr.u_name_values["speed"]= 2;
gr.update()
}
//wrapped inside a function
function updateNameValue(table, field, sysId, propertie, value){
var gr = new GlideRecord(table);
if (gr.get(sysId)) {
gr[field][propertie]= value;
gr.update();
}
}
updateNameValue("incident","u_name_values","b9a633db4f1a930035e0fdb28110c728",
"speeds", "sspeed", 2);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2018 08:44 AM
In GlideRecord you can just update the value, by passing the name and value on the element.
If it exits, the value will update, if not, the name value pair is added.
var gr = new GlideRecord('incident');
if (gr.get('b9a633db4f1a930035e0fdb28110c728')) {
gr.u_name_values["speed"]= 2;
gr.update()
}
//wrapped inside a function
function updateNameValue(table, field, sysId, propertie, value){
var gr = new GlideRecord(table);
if (gr.get(sysId)) {
gr[field][propertie]= value;
gr.update();
}
}
updateNameValue("incident","u_name_values","b9a633db4f1a930035e0fdb28110c728",
"speeds", "sspeed", 2);