How can we submit Record Producer on a Target table along with the mapping of variables?

Surbhi16
Tera Contributor

Hi @Mark Roethof , @Ankur Bawiskar 

 

"I need to submit a Record Producer via script to a target table, 'Workplace Service', including mapping the variables. The form includes a section displaying all the Record Producer's variables, and I want to ensure that when a user submits the Record Producer, their variable inputs are correctly mapped to the form."

7 REPLIES 7

Is it on purpose that also the structure of setRequestBody is different in your last reply? Your first reply was working code right, only hardoded? So why not replace for example:

 

'603a717387073d10627cc8470cbb3544'

 

with:

 

vaInput.something_that_is_a_sys_id

 

And ofcourse add some debugging, to confirm if the vaInputs contains what you think it should contain.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi @Mark Roethof 

Reason why I am not able to use vaInputs.Node name here is getting an issue with Double quotes which is present at start and end on below line:

 

request.setRequestBody("{'variables':{'requested_for':" + vaInputs.requested_for + ",'priority':"+vaInputs.priority}, 'short_description':'test','workplace_service':'603a717387073d10627cc8470cbb3544','workplace_service_item':'35b9d6291b754a90217c9686b04bcb7a'}");

 

I don't get an option to type in vaInputs.node name as it considers it as a complete string because of double quotes.

 

I have tried adjusting the string quotes and then use concatenation (+) to allow vaInputs to being used but I am unsuccessful here.

 

Can you help me on how can I adjust above line to make use of vaInputs command here.

The quotes issue was not in your earlier response which was working you mentioned, so why is it suddenly now?

 

// Setting up the request body with dynamic variables
    request.setRequestBody(JSON.stringify({
        'variables': obj,
        'short_description': 'test',
        'workplace_service': '603a717387073d10627cc8470cbb3544',
        'workplace_service_item': '35b9d6291b754a90217c9686b04bcb7a',
        'u_category': 'Request Catering Assistance'
    }));

 

Just change that, in for example:

 

// Setting up the request body with dynamic variables
    request.setRequestBody(JSON.stringify({
        'variables': obj,
        'short_description': 'test',
        'workplace_service': vaInputs.something,
        'workplace_service_item': vaInputs.something2,
        'u_category': 'Request Catering Assistance'
    }));

 

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn