Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Adding Requested for and other fields to a Approval Record and Approval Form

MaximilianZ5054
Tera Contributor

Hi all,

 

I'm currently a bit helpless about this topic I would have assumed is fairly simple.

 

My first problem is related to the approval record. I just added two html lines, one to show the requested_for which perfectly works out and the second was for "special_instructions", which are part of the sc_request table.

Given that there is a reference relation between these tables, I hoped I could just use {{::task.request.special_instructions.display_value}} in the HTML Body. But sadly this doesnt work. I don't use HTML often, can this easily be done by just replacing a few commands, or do I have to do much more? The reference already exists with "request", all I want is to show the display value for the 'special_instructions' field on the side.

 

The second problem is adding these fields to the Approval form. Again, I assumed this should be very easy, because you just have to configure the layout and use the already existing reference fields. With approval_for you have a build in reference to the task table. But despite the fact that you can click the numbers field in the task table to immediately go to the desired request where the requested_for is in, it doesnt count as reference field to dot to the needed fields.

 

(And a addition point I noticed: The task table has a columm named "Requested for [Requested Item]". But this columm doesnt exist under the table columms. I clicked all the buttons I could think of, but I have no clue how you create or use this. It isn't considered a reference field, and the Layout List only allows to add ro remove them, but not create them. But thats just a side note and not my priority.)

3 REPLIES 3

magee
Tera Guru

Hey Max,

Can you just not dot-walk from the approval record and pull in the requested_for (from RITM i'm assuming) and special instructions (from the sc_request)?

Sreeram Nair
Tera Guru

I think you’re mixing syntaxes: {{...}} is Service Portal/Angular, but email/notification HTML uses ${...} (or a mail script). For an Approval tied to a Request Item (RITM), the approval record (sysapproval_approver) points to the target in sysapproval; so in your notification body use dot-walking like ${approval.sysapproval.request.special_instructions} to read the REQ’s special_instructions, or if the approval targets the REQ directly, ${approval.sysapproval.special_instructions}.

 

For showing those values on the Approval form, the out-of-box way is to add the Approval Summarizer formatter (or create display/reference fields and fill them with a UI Policy/Client Script); the form itself doesn’t treat approval_for as a dot-walk source the way lists do. That odd list column “Requested for [Requested Item]” is just a dot-walked list column, (e.g., requested_item.request.requested_for) you create those from the list layout by expanding the reference field and picking the nested attribute.


ɪꜰ ᴍʏ ᴀɴꜱᴡᴇʀ ʜᴀꜱ ʜᴇʟᴘᴇᴅ ᴡɪᴛʜ ʏᴏᴜʀ Qᴜᴇꜱᴛɪᴏɴ, ᴘʟᴇᴀꜱᴇ ᴍᴀʀᴋ ᴍʏ ᴀɴꜱᴡᴇʀ ᴀꜱ ᴛʜᴇ ᴀᴄᴄᴇᴘᴛᴇᴅ ꜱᴏʟᴜᴛɪᴏɴ ᴀɴᴅ ɢɪᴠᴇ ᴀ ᴛʜᴜᴍʙꜱ ᴜᴘ.




ʙᴇꜱᴛ ʀᴇɢᴀʀᴅꜱ


ꜱʀᴇᴇʀᴀᴍ

I copied the Syntax used in the Approval Record. So it should be the service portal/angular syntax. I essentially just copied <div ng-if="task.short_description">{{::task.short_description.display_value}}</div> and tried to edit it so that it fits my need. (The copied line should be part of base service now, because I copied SP - Core widget)

Is it possible to dot walk with this?

 

I will try adding the reference field. I hoped it would be easier, because you already could dot-walk it.