show record values in HTML field in backend, NOT SP NOT widgets

woodyfairley
Tera Guru

Hello Experts, I wish you all well.

I am using HTML fields in my form to allow users to add their content to the backend form similar to the "Build Terms and Conditions" UI Action and how it allows users to create records containing language blocks (terms and conditions for a contract) into the form itself in the backend. In the PDI the UI Action is named: "build_terms" on the table: "ast_contract".

They want to incorporate field values directly into their HTML content, but I do not know how to enable this directly within the HTML field, similar to a UI Macro.

I am doing this for them in the UI Macro language by using "$[current.field_name]" to display the field's value, but they want to replicate this same behavior in their HTML field content blocks so that a record's field value is inserted into the text when the setValue happens. I will continue my research and add a solution when I find it, but hoping one of you experts can show us the right way to do this. My initial psuedo-code is as follows:

The table I am using for the Service Descriptions (HTML-formatted user input):

0. USER IS ENTERING INFORMATION INTO A HTML FIELD AND WANTS TO REFER TO A FIELD VALUE IN THE AGREEMENT RECORD

1. var hotAgreement = new GlideRecord(agreement_table);

2. hotAgreement.get(g_form.getValue(agreement_reference_field_in_service_record);

3. USE HOTAGREEMENT FOR VALUES COLLECTION AND ASSIGNMENT IN HTML FIELD

4.

The table containing the contract/agreements (target for service descriptions)

1. USERS CLICK THE BUILD AGREEMENT TERMS CUSTOM UI ACTION, THIS PART WORKS

2. HTML CONTENT CONTAINS VALUES FROM THE AGREEMENT RECORD FIELDS, WANT TO DO THIS

Kind Regards,

Woody

15 REPLIES 15

woodyfairley
Tera Guru

Just freshening this request with some ideas: I think it may involve loading the record's field values into a variable to reference in the html, similar to how a UI Page form behaves but without Jelly, and with some manually added templated scripts that preload with the TinyMCE editor via client script. I will test it this week and offer my insights.

 

The project will eventually become a service portal, which should allow the behaviors I am seeking, perhaps in a way I have not yet learned.

After more research, I think I can do this with g_scratchpad. Unfortunately, scratchpad collects string values, so my business rule will need to be rather exhaustive with declarations; I will basically need to create an array with every field name + its value, and use the name to create the scratchpad variable and then assign its value (e.g. g_scratchpad.number = current.number.getDisplayValue();).

Then, I can reference the scratchpad values by field name (e.g. var number = g_scratchpad.number), but I prefer adding some code to the business rule that I can then manipulate in a client script in the custom form so that a specially named variable automatically gets the assigned value, (e.g. var ^^number = g_scratchpad.^^number). My vision is that this works similar to UI Page or UI Macro pre-defined variables can access the field values in the interesting table with $[number].

My big obstacle to this approach is how to incorporate the scratchpad variables into the html. Can anyone share some ideas? Perhaps I can open the code view in TinyMCE and add a <script> block and assign the scratchpad values to variables within the html code?

I'm curious, why not use a UI Page or UI Macro or better yet a custom fields on the form itself?