Use HTML Tags on a Custom Field Using Workflow Action Script

Dynamically set text values with HTML tags via workflow.

Solution

As an example, we will use the Invoice record type for this scenario with the assumption that we are going to use it in an HTML tag-supported field (i.e. Inline HTML or Rich Text Box).

1. Create a JavaScript file with the following codes

function workflowAction(id,type,form) {‌ 

            if(type == ‘create’){‌ 

                  var stringval = nlapiGetContext().getSetting(‘SCRIPT’,’custscrip1′).replace(/&lt;/g,'<‘).replace(/&gt;/g, ‘>’);  

                  nlapiSubmitField(“invoice”, nlapiGetRecordId(), “instructions_field”,stringval);  

             } 

       }

2. Create and Deploy the script:

Type: workflow Action Script

name: workflow_action_script.js

function: workflowAction

parameters: Text to Set (custscrip1) – Free Form Text

Save

applies to: invoice

status: released

log level: debug

execute as: administrator

roles: all roles

save

3. Create a workflow

Name: Set HTML tags via Workflow

Record Type: Transasction -> Invoice

Initiation: Event based

Event Definition: On Create

Trigger: After Record Submit

Save

4. Create a state field:

Name: Text to set

Type: Free-Form Text

Save

5. On State 1:

Name: Set HTML tags via Workflow

Record Type: Transasction -> Invoice

Initiation: Event based

Event Definition: On Create

Select

Name: Text to set

Type: Free-Form Text

Create a new Action: Workflow Action Script (Custom)

Trigger On: Entry

On the Parameter Section:

Text to set: Value Field -> Text to set(state)

Save

6. To add the text that we want to set, we can go to the state field and add a default value or create a new action (i.e. set field value).

Leave a comment

Your email address will not be published. Required fields are marked *