Multiple Row Variable Set showing Catalog Client Script SyntaxError: Unexpected end of JSON input and Empty JSON Value

Edwin Ng
Tera Expert

Hi,

I am trying to compute the total value of 1 of the column in the MRVS and displayed onto a variable in the record producer as shown below:

find_real_file.png

I have followed the guide from the below link but to now avail.

Not able to retrieve Multi Row variable set data using onSubmit client script - IT Service Managemen...

From the below catalog client script, I have encountered error due to the parsing of the g_formGetValues. I also found out that the result of console.log(g_form.getValue('billing_request_insert_details')) is returning empty values despite I have filled the relevant field in the MRSV.

find_real_file.png

Catalog Client Script

find_real_file.png

MRSV in preview

find_real_file.png

Error in Console

find_real_file.png

Details of MRSV

I would appreciate if anyone could assist on my problem.

1 ACCEPTED SOLUTION

Kartik Sethi
Tera Guru
Tera Guru

Hi @Edwin Ng 

 

You can follow my reply to a similar community thread:

Add the total cost in multirow variable set

This thread might give you the required solution. Please check and let me know if you still face the issue.


Please mark my answer as correct if this solves your issues!

If it helped you in any way then please mark helpful!

 

Thanks and regards,

Kartik

View solution in original post

11 REPLIES 11

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

can you share your script here instead of script screenshots?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Edwin Ng 

onSubmit of MRVS variable set won't work

Please change the onSubmit to Applies to Catalog Item and then it would work fine

you will get JSON; you will get total etc

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

Please see below script as requested.

I have applied the below script to a variable set (You can refer to screenshot on the catalog client script). 

Thanks.

function onSubmit() {
    //Type appropriate comment here, and begin script below
    var multiRowVariableSet = JSON.parse(g_form.getValue('billing_request_insert_details')); // Replace your variable set Name and not label here.
    var totalCost = 0;
    for (var i = 0; i < multiRowVariableSet.length; i++) {
        totalCost += multiRowVariableSet[i].billing_request_gst_amount_s; //add all totals from the MRVS to 1 total
    }
    alert(totalCost);
}

So what was the outcome?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

I have changed as advised but no alert is triggered. I think I need to create a submit button/variable for the catalog item for the onSubmit to work.

Since the widget approach as guided by Kartik is working, I will stay as it is.

Anyway, thanks for your help Ankur