Home › Forums › Classic DFFS › Create field with people picker data
Tagged: date field, people picker field, spjs
- This topic has 2 replies, 2 voices, and was last updated 7 years, 1 month ago by David Salewski.
-
AuthorPosts
-
-
September 20, 2017 at 15:53 #18222
Hi there!
I am trying to create a new list item with JavaScript which works perfectly but for two types: dates and people picker. I used the following manual for the process:
Create a new item in list B prefilling common fields from list A.
So I am now trying to fill up the data array.If I want to populate an item with data from a people picker field, I get an error code. The code is 0x80020005. I tried several methods to get the data, but none seem to work:
data.INTERNAL_FIELD_NAME = getFieldValue('INTERNAL_FIELD_NAME',''); data.INTERNAL_FIELD_NAME = spjs.utility.getFieldValue({"fin":"INTERNAL_FIELD_NAME","delimiter":",","key":"loginName"}) data.INTERNAL_FIELD_NAME = spjs.utility.userInfo(spjs.utility.getFieldValue({"fin":"INTERNAL_FIELD_NAME","delimiter":",","key":"loginName"}));
They all provide me with the same error
The date field also does not work. I tried to regex my date format to the needed one, but it still throws an error.
var raw = getFieldValue('Liefertermin','').split(/[.]/); var dateString = raw[2]+"-"+raw[0]+"-"+raw[1]+" 00:00:00";
This codes takes my date format (20.09.2017) and converts it to “2017-09-20 00:00:00”. I tried both with and without the time.
Do you have any tips for me, which could help?
P.S.: The versions I use are
DFFS Backend v4.4.2.9|
CSS version: 4.21 / 4.21|
spjs-utility version: 1.279 -
September 27, 2017 at 18:49 #18290
Sorry for the delay. To update a People picker with code, you must pass the ID like shown here:
var login = spjs.utility.getFieldValue({"fin":"INTERNAL_FIELD_NAME","delimiter":",","key":"loginName"}); var userId = spjs.utility.userInfo(login).ID; data.INTERNAL_FIELD_NAME = userId;
The date value must be passed like this:
spjs.utility.updateItem({"listName":"YOUR_LIST_DISPLAY_NAME_OR_GUID","id":"YOUR_ITEM_ID","data":{"COLUMN_NAME":"2017-09-20 00:00:00"}});
Alexander
-
September 29, 2017 at 14:55 #18309
Both worked perfectly, thanks!
-
-
AuthorPosts
- You must be logged in to reply to this topic.