Getting Error - MRVS Data fetch RITM to catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 07:59 AM
I am trying to copy the MRVS data from an existing RITM and put it in a new catalog item by using GlideAjax, and when I am trying to put the request in the cart or submit, it gives me an error: "Something went wrong on your request; it could not be submitted. Please contact your system administration."
I used the following method, but it didn't work. Does anyone have a solution for this or have come across this issue before?
Server side -
getMRVS:function(){ //var aa={}; var gr=new GlideRecord('sc_req_item'); gr.get('444db8712f96b01042162b5df699b654'); var mrv=gr.variables.my_values.toString(); return JSON.stringify(mrv); }
Client side -
var gr=new GlideAjax('AjaxUtil'); gr.addParam('sysparm_name','getMRVS'); gr.getXML(GetMRVS); function GetMRVS(response){ var answer = response.responseXML.documentElement.getAttribute("answer"); var mrv=JSON.parse(answer); console.log(mrv); g_form.setValue('my_values',mrv); }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 08:28 AM
Setting the value of the MRVS on the current form is going to be looking for a string, so try it without the JSON.parse line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 11:03 AM
@Brad Bowman Still getting the same error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 05:47 AM
Similarly, you don't need to JSON.stringify the existing JSON-formatted string value in the Script Include. To follow clean coding standards to reduce errors or unexpected results, you should always put a GlideRecord get or next() inside of an if or while condition so that the following code is only executed if the record is found. You should also always return something from a Script Include, so declare the return variable at the beginning, outside of any if conditions, and make sure the return is also outside of any condition blocks. I got this scenario to work without error with these scripts. I'm using the native UI by the way - it may work differently in Service Portal / Employee Service Center / ...
var gr=new GlideAjax('AjaxUtil');
gr.addParam('sysparm_name','getMRVS');
gr.getXML(GetMRVS);
function GetMRVS(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('my_values', answer);
}
getMRVS: function() {
var mrv = '';
var gr = new GlideRecord('sc_req_item');
if (gr.get('444db8712f96b01042162b5df699b654')) {
mrv = gr.variables.my_values.toString();
}
return mrv;
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 11:43 AM
@Brad Bowman Unfortunately I am still getting same error.