June 20, 2019 at 13:52 #25826
Looking for a method to create a semicolon-plus-space separated value from a People Picker Multivalue field. The issue is that my environment uses lastName, firstName format. Leveraging setFieldValue() or Rule-Set field value methods does allow me to move the PP value into a string, but the format looks odd: 1firstName, 1lastName,2firstName, 2lastName (note that the values are separated by a comma).
If I use a QuickEdit view of the multivalue People Picker and my target string field, and then simply copy from PP to string, the result is 1firstName, 1lastName; 2firstName, 2lastName (note that the values are separated by a semicolon-plus-space).
Can you suggest a JS method I can use in Custom JS that would emulate the result of QuickEdit copy-n-paste?
As always, I appreciate your support and efforts!
R’grds – Ben.
DFFS frontend: 188.8.131.52 – March 31, 2019
DFFS frontend CSS: 4.46 / 4.46
Autocomplete: 1.6.28 – January 12, 2019
Cascading dropdowns: 3.7.26 – March 31, 2019
Lookup: 1.1.16 – March 05, 2019
Resource management: not loaded
SPJS-Utility: 1.332 – March 05, 2019
vLookup: 2.2.129 – March 07, 2019
June 20, 2019 at 15:59 #25831
You can use an array like this if you set the value with setFieldValue:
In general, using the login name is preferred over display name when setting the value, but if you don’t have the login name available you would need to run some custom js to get it based on the display name or ID of the user.
June 20, 2019 at 17:18 #25837
Sorry – I have been unclear… The problem is in the formatting of the result as a string.
In this example, the resultant string is correct – but formatted poorly:
If mySPFieldUserMulti contains two names, that value is set to the string field mySPFieldText separated by a comma and is where the poor formatting comes in. Like this: mySPFieldUserMulti contains two names:
- Doe, Jane
- Public, John
The result in mySPFieldText will be:
Doe, Jane,Public, John
Note that there is no space after the comma between Jane and Public. This is the same result if I use a rule to set the field value.
What I would like to achieve is the result string to be formatted as
Doe, Jane; Public, John
Note that there is semicolon-and-space used to separate the two values.
Thank you for your consideration.
R’grds – Ben.
June 20, 2019 at 22:32 #25839
When you use getFieldValue on a multichoice field, the returned value is an array. This means you can set the value like this:
June 21, 2019 at 14:12 #25843
Thank you – you never disappoint! This method is exactly what I needed, and a good lesson. As always, I appreciate your support and efforts!
R’grds – Ben.
June 21, 2019 at 16:12 #25845
Thanks, I’m glad it worked!
- You must be logged in to reply to this topic.