Crow Canyon Software Forum

Forum Navigation
Please or Register to create posts and topics.

Form Event Action to Concatenate multiple field values where one is a lookup - need the lookup value not the ID

Hello -

I'm trying to create a form event action that concatenates multiple field values where one is a lookup.  I'm trying this by formatting the value using javascript, and have found the following where Department is a lookup into the list Departments, and the column is set to get the information from the Departments->Department column:

_ccs_FormUI.fetchColumnValueUI("Department");   returns "ID;#Department Name" we just need the Department Name

_ccs_FormUI.fetchColumnValueForLookup("Department"); returns only the lookup ID

Is there a method to get just the displayed value (in this case department name) from the lookup in Javascript , or do I need to just split the value returned from _ccs_FormUI.fetchColumnValueUI on #?

Thank you in advance!

Brian.

 

Uploaded files:
  • Fetch-Lookup-Value.gif

What about setting up another text field (named FormattedDept) and setting the action when the Department Name lookup field is changed to set the value of FormattedDept to $formatvalue([FormattedDept|FormattedDept]).  Then you can use this new field in your concat.

Hi @briankoch,

This can be done in multiple ways, below we describe doing this with NITRO Forms variables and functions.

First step:

Define a variable and store the lookup column display value in it. Refer to this article: https://www.crowcanyon.help/article/679/
Declare a variable, say with name - LookupDisp
Configure a Form Event Action on column value change for the lookup column. In that action set the variable value. We will use formatvalue function to get the text value of the lookup column. You can use the UI to set this, it will look something like this:

$formatvalue([Lookup Search|LookupDemo])

Second step:

Use the above variable. We can set this variable value in a column directly. With form event actions - update form controls action, we can directly select the variable in UI and mapping will look like: LookupDisp##value.

We can use strcat function to concatenate multiple column values.

Example: $strcat([ChoiceSingle|ChoiceSingle], - ,LookupDisp##value)

In case you need the lookup display value in JavaScript directly, please use below code.

----------------------------------
var lookupVal = window.ccs_g_FormUI.GetVariableValuebyName("LookupDisp");
if(lookupVal && lookupVal.hasOwnProperty('ComputedStringValue'))
{
    return lookupVal['ComputedStringValue'];
}

return '';

--------------------------------

Articles related to these configurations:

Custom Script examples in NITRO Forms

Syntax for expressions in NITRO Forms