add multiple fields in system properties and send that field when rest message is called

komaladsul
Kilo Guru

hello all,

add multiple fields in system properties and send that field when rest message is called.means want to send dynamic field name in integration.

please help

1 ACCEPTED SOLUTION

If you have nested data object in your responseBody then you can use something like this:

var fields = gs.getProperty('propertyName').split(',');
for (var index in fields) {
     var field = fields[index];    
     customBodyObject.data[inputs] = current.getValue(field); //here customBodyObject is object that your are preparing and data is abother object in your jsonBody. current is GlideRecord obj
                    
                }

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can create system property to hold comma separated values.

but what exactly is required here once you get the system property value using gs.getProperty

Regards
Ankur

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

Community Alums
Not applicable

Hi,

You have to pass something like this in ur script include to make it work in REST

 Below is the example of JIRA 

 r.setStringParameter('base_endpoint', gs.getProperty('com.snc.integration.jira.base_jira_instance_url'));

 

Please mark my answer as Correct & Helpful, if applicable.

Thanks

Sandeep

Anil Lande
Kilo Patron

Hi,

You can use comma separated list as value in system property and use it in your script while preparing response/request body.

var fields = gs.getProperty('propertyName').split(',');
 for (var index in fields) {
                    var field = fields[index];                    
                        respBodyObj.setValue(field, current.getValue(field));  //here respBodyObj is object that your are preparing and urrent is GlideRecord obj
                    
                }

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

If you have nested data object in your responseBody then you can use something like this:

var fields = gs.getProperty('propertyName').split(',');
for (var index in fields) {
     var field = fields[index];    
     customBodyObject.data[inputs] = current.getValue(field); //here customBodyObject is object that your are preparing and data is abother object in your jsonBody. current is GlideRecord obj
                    
                }

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande