- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2019 02:09 AM
Hi,
I've been trying to set the value of a field in incident form through a record producer(accessd from service portal). Now I am using a script include in an onsubmit client script to get this value.
function onSubmit() {
//Type appropriate comment here, and begin script below
var p = g_form.getValue('Asset_Tag');
var ga = new GlideAjax('Get_asset_tag'); //Name of the Script Include
ga.addParam('sysparm_name', 'asset_tag'); //Name of the function in the script include
ga.addParam('sysparm_sys_id', p); //Parameter to pass to the script include g_form.getValue('Asset_Tag')
ga.getXML(CheckAssetTag);
function CheckAssetTag(response) {
var y = response.responseXML.documentElement.getAttribute("answer");
alert(y);
// var r = y;
g_form.setValue("description",y);
}
}
The alert works fine here and gives perfect value however not sure why this is not setting the value. This is only happening when i am using script include. I think I am making a very little mistake but not able to find it out.Looking for help.
THanks
Solved! Go to Solution.
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2019 03:16 AM
the reason for your issue is: the form is submitted to server before your glideAjax return value.it wont be visible to you because it will happen in milliseconds it will look like it was ubmitted after receiving the response but technically it will be submitted before getting response from server. you need to make your aJax call to synchronus call to wait for response before submitting form or you can modify it to onchange client script to fix this.
suggestion:
is description refers a variable in your record producer? or field in incident?
if it refrs to a variable in record producer form- it is of no use because you are populating a value in form during submit. Instead replace your ajax call into server function script section of record producer.
set the result to incident directly using the below:
current.description = new Get_asset_tag().asset_tag(producer.Asset_Tag);
add the above code to your script section of your record producer.
need slight changes in your script include function to make this working, share your script include if need any assistance in doing that.
-satheesh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2019 02:14 AM
are you sure the variable name is correct ?
quick question here, once you will submit the record producer here it will create record , so have you mapped that with field ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2019 03:45 AM
Variable name is correct, I am getting the value in the alert. What mapping is required in this case can you please explain?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2019 03:58 AM
i am assuming here, you have variable "description" on your record producer , if you will open that variable , you will see map to field check box, so here you need to map that variable to target table column .
Example: i have my record producer on incident table and i have variable description, so i will open the description variable on record producer and checked the map to field check box and in field drop down i will select the Description column .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2019 04:04 AM
Description variable was there on the previous record producer. I've made this inactive. So now description field is not linked to any specific variable because it has to get the value from multiple variables. Writing the exact requirement over here.
The required functionality is to get the values from multiple fields(variables) of the form(record producer) and set their concatenation within one field(description). All the fields were either string or choices except this once(reference). When I tried the getvalue and setvalue it is working for all other fields but in this field(asset_tag) i am getting the sys_id of selected records. For this i've created a script include and retrieved the displayvalue thorugh gliderecord and when placed the scriptinclude within my client script it is retrieving the exact value within the "alert" however not setting the value of description. I am unsure if script include works on record producers or not