HR Tasks - variables are not populated in the portal, but are populated inside hr task record

Andr_1
Tera Contributor

Hi.

 

I have a flow with an action to create an HR task and send that HR task to someone to be visible in the portal. The objective is for the user to access the portal and send some variables with information. Some of these variables must already be populated and read-only, so this user cannot change these variables.

Andr_1_0-1721059793422.png


The task is created, associated to a hr case and it will appear on the portal for the user.

Andr_1_1-1721059865432.png


Now, the problem is that on the portal, the autopopulated variables (first screen shoot) are not appearing with the values

Andr_1_2-1721059983837.png
But if we look into the backend...

Andr_1_4-1721060172972.png

 

...the variables are populated with the information provided on the flow.


How can I show also the variables populated on the portal?

 

Thank you

André Ramos

1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron
Tera Patron

@Andr_1 Usually the variable and their values are stored in question_answer table for record producers, you need to write an onLoad client script and a script include to make a query to this table via a GlideAjax call. Once the values are received in the call back, you can set the field values using g_form.setValue() method.

View solution in original post

6 REPLIES 6

Sandeep Rajput
Tera Patron
Tera Patron

@Andr_1 Usually the variable and their values are stored in question_answer table for record producers, you need to write an onLoad client script and a script include to make a query to this table via a GlideAjax call. Once the values are received in the call back, you can set the field values using g_form.setValue() method.

Hi @Sandeep Rajput   

thank you for your response.

How can I do it?  To make the query on the question_answer table, I need to know the hr task sys_id... How can I get this sys id on the onload script?
Can you give me a short example please?

@Andr_1 I create an article around this here to get the HR task sys_id https://www.servicenow.com/community/hrsd-articles/fetching-subject-person-details-on-a-record-produ.... You can follow the steps mentioned in this article to get the sys_id of the current hr task.

 

Hope this helps.

Thank you for your help
Your article looks nice... but I don't need this complexity

I found a better way to get the sys_id via URL through catalog client scripts

    var url = top.location.href;
    var value = new URLSearchParams(url).get('sys_id');