Not getting proper output

Community Alums
Not applicable

Hi All,

 

I have used this script :

 

var gr=new GlideRecord('incident_task');
gr.addQuery('sys_id','f9f3a80e476dbd1065296439736d4ke3');
gr.query();
if(gr.next())
{
 
    var result=new test().getSymptoms(gr.incident.parent.u_symptom.getDisplayValue());
    gs.info(result);
    var obj={
                "name": "symptoms",
                "value": result,
                "valueType": "string",
                "@type": "symptoms"
    };
gs.info(JSON.stringify(obj));
    gs.info(new test().getSymptoms(gr.incident.parent.u_symptom.getDisplayValue()));
 
This is the Output that I am getting : 
 
ServiceDegradation
{"name":"symptoms","value":{},"valueType":"string","@type":"symptoms"}
ServiceDegradation

What I want to understand is that why am I getting "{}" inside "value" of "obj" and not "ServiceDegradation" which is the proper output that I should get. Whereas if you see that if  I try to use gs.info() then I am getting the proper value from the function that is "ServiceDegradation". Please note that I tried using JSON.stringify() as well but I am still getting the same thing ,i.e. {} inside value

1 ACCEPTED SOLUTION

Ahmmed Ali
Mega Sage

Hello @Community Alums 

 

What type of data you are returning from the script include at 

var result=new test().getSymptoms(gr.incident.parent.u_symptom.getDisplayValue())

 

try returning string from the script include or modify the above statement as

var result=new test().getSymptoms(gr.incident.parent.u_symptom.getDisplayValue()) + "";

 

Thank you,

Ali

 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

View solution in original post

2 REPLIES 2

Ahmmed Ali
Mega Sage

Hello @Community Alums 

 

What type of data you are returning from the script include at 

var result=new test().getSymptoms(gr.incident.parent.u_symptom.getDisplayValue())

 

try returning string from the script include or modify the above statement as

var result=new test().getSymptoms(gr.incident.parent.u_symptom.getDisplayValue()) + "";

 

Thank you,

Ali

 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Community Alums
Not applicable

Hi @Ahmmed Ali ,

 

var result=new test().getSymptoms(gr.incident.parent.u_symptom.getDisplayValue()) + ""; 

 

The above line gave the proper result.

 

Thanks,

Hrithik Nirupam