- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2022 10:29 PM
Hi,
I have a catalog client script which is passing the table field name (assignment_group) to the script include.
On the script include i have queried the table and i am trying to update the new field value.
Client Script:
var ajax = new GlideAjax('UpdateCMDBFieldValues'); //Script Include Name
ajax.addParam('sysparm_name', 'updateField'); // Function Name
ajax.addParam('sysparm_value', getList); // Server Name
ajax.addParam('sysparm_value2', storeValue); // Assignment Group Sys_id
ajax.addParam('sysparm_value3', fieldName); // Name of the field (assignment_group)
ajax.getXML(getReturnValue);
function getReturnValue(answer) {
alert("Inside getReturnValue");
}
Script Include:
var pushedValue = this.getParameter('sysparm_value'); // Server Name
var newValueToUpdate = this.getParameter('sysparm_value2'); //Assignment Group Sys_id
var fieldType = this.getParameter('sysparm_value3'); // Field Name (assignment_group)
var gr = new GlideRecord("cmdb_ci");
gr.addQuery('name', pushedValue );
gr.query();
if (gr.next()) {
gs.log("BNG - inside if block of gr.next()");
gr.fieldType = newValueToUpdate;
gr.update();
}
The problem is with the line gr.fieldType as the table "cmdb_ci" does not have a field name called "fieldType" it is not able to updated the assignment_group.
As the fieldType variable has the value "assignment_group".
Can you please help me find a way to concat or convert the fieldType variable into assignment_group?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2022 07:12 AM
Try to use gr.setValue('field_name',value ) and pass trhe field name and value here .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2022 07:04 AM
Hi Saurav,
We just have to figure out if we can concate a variable value with the GlideRecord as below.
gr.fieldType = newValueToUpdate;
As the variable fieldType will store the value "assignment_group" which is the field name that is passed from the client script to the script include. Please refer the above code for more details.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2022 11:28 PM
Hello
Call Back Function is Missing in Your Client Script.
Syantax:- var ans = response.responseXML.documentElement.getAttribute("answer");
Mark my Response as Correct or Helpful, if you find it Appropriate.
Gaurav Shirsat
https://www.linkedin.com/in/gauravshirsat/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2022 04:39 AM
Hi,
Yes, We do not want any return values back from the script include.
So we do not use.
var ans = response.responseXML.documentElement.getAttribute("answer");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2022 07:12 AM
Try to use gr.setValue('field_name',value ) and pass trhe field name and value here .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2022 07:19 AM
Hi Anurag,
Works like a charm. Thanks a lot.