How to validate if list collector has no value in record producer script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2019 03:08 PM
Please can someone help as I have tried what I think is everything and can't get this to work. I'm worried I might be going around in circles and stuck focusing on one thing and maybe missing something really straight forward.
What is the correct syntax to validate if a list collector has no value in a record producer script?
currently this is my code:
var clients = "";
clients = producer.u_primary_client.getDisplayValue();
var additionalClients = producer.u_portfolio_list.toString();
if (additionalClients !="")
{
clients += ", " + producer.u_portfolios_list.getDisplayValue();
}
current.u_clients = clients;
On my form when nothing is selected in u_portfolio_list (list collector) and the field is left completely blank it still enters the IF statement and prints the primary client followed by a comma.
I have tried all of the following:
if (additionalClients !== "")
if (additionalClients !== NULL) and if (additionalClients != NULL)
if (producer.u_portfolio_list.getDisplayValue() !== "") and if (producer.u_portfolio_list.getDisplayValue() != "")
if (producer.u_portfolio_list. !== NULL) and if (producer.u_portfolio_list. != NULL)
When empty and I print gs.addInfoMessage(producer.u_portfolio_list.toString()) it returns 'undefined' so I have even tried if (producer.u_portfolio_list.toString() == "undefined").
In all these cases the code enters the IF statement and prints the ', '.
Any advice...even if I'm missing something really stupid would be greatly appreciated as this is just doing my head in and wasting sooo much time.
Thanks.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2019 04:03 PM
var clients = '';
clients = producer.u_primary_client.getDisplayValue();
if (producer.u_portfolio_list != '') {
clients += ", " + producer.u_portfolios_list.getDisplayValue();
}
current.u_clients = clients;
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2019 04:05 PM
or perhaps:
var clients = '';
clients = producer.u_primary_client.getDisplayValue();
additionalClients = producer.u_portfolio_list.toString().split(',');
if (additionalClients.length > 0) {
clients += ", " + producer.u_portfolios_list.getDisplayValue();
}
current.u_clients = clients;
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2019 04:55 PM
I found the problem.....typo in the variable name...complicated variable names always tend to cause problems.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2019 05:23 AM
Yea....
Please at least mark other replies as Helpful if they were. You ended up getting two of the best members of these forums helping you out. dvp and sanjiv.
Thanks..
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!