Create field with people picker data

Forums Dynamic Forms for SharePoint Create field with people picker data

This topic contains 2 replies, has 2 voices, and was last updated by  David Salewski 9 months, 2 weeks ago.

  • Author
  • #18222

    David Salewski

    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 = 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

  • #18290

    Alexander Bautz

    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"}});


  • #18309

    David Salewski

    Both worked perfectly, thanks!

You must be logged in to reply to this topic.