addItem on NewForm JS getting SP error x0800200005

Forums SPJS-Utility addItem on NewForm JS getting SP error x0800200005

Viewing 2 reply threads
  • Author
    Posts
    • #36548
      DougMcCourt
      Participant

      Hi Alexander –

      Have encountered an “unexpected” sharepoint error when trying to us addItem in a js on NewForm that you helped me with 2 yrs ago.

      Im trying to capture a bunch of boolean / checkboxes, and several lookup fields on newform – and use addItem to add the data to the list, the pass the ID of the newley created list item to the Edit for for further processing.

      If the code takes the path where (p==’C’) – all works fine.
      If the code takes the path where (p==’N’) – sharepoint complains with the x08020005

      ive used console to verify that all of the getFieldValues are retruning what is expected – so im thinking i must have done something silly / incorrect when adding the field values to the data. array

      Any guidance would be appreciated!!

      Here is the code:

      function saveAndRedir(){
      var ok = spjs.dffs.check_Mandatory([“Title”]), data = {}, newItem, p = getFieldValue(“IsCross”), url;
      var parm = “&”+location.search.substring(1);
      if(ok){
      data.Title = getFieldValue(“Title”);
      data.ContentTypeId = “0x0100B025F82EDB149249B2600F0619316DAC”;
      if (p==”C”) {
      data.ContentTypeId = “0x0100CEF026DC41DEB74C9A05C6AE6E1B7E1E005273FFB34EEBDF4B9AB96EAB91662862″;
      }
      if (p==”N”) {
      /* next 4 ifs are for checkboxes
      if (getFieldValue(“Transport_x0020_Work”)) {
      data.Transport_x0020_Work = 1;
      }
      if (getFieldValue(“Transformation_x0020_Work”)) {
      data.Transformation_x0020_Work = 1;
      }
      if (getFieldValue(“New_x0020_Use_x0020__x002f__x002”)) {
      data.New_x0020_Use_x0020__x002f__x002 = 1;
      }
      if (getFieldValue(“Maintain”)) {
      data.Maintain = 1;
      }

      /* next 4 fields are lookup fields
      data.Source_x0020_Entity = getFieldValue(“Source_x0020_Entity”);
      data.Source_x0020_Residency = getFieldValue(“Source_x0020_Residency”);
      data.Target_x0020_Entity = getFieldValue(“Target_x0020_Entity”);
      data.Target_x0020_Residency = getFieldValue(“Target_x0020_Residency”);

      /* Next 5 ifs are for checkboxes
      if (getFieldValue(“Border_x0020_Crossing”)) {
      data.Border_x0020_Crossing = 1;
      }
      if (getFieldValue(“Req_x0020_Has_x0020_PII_x002f_MN”)) {
      data.Req_x0020_Has_x0020_PII_x002f_MN = 1;
      }
      if (getFieldValue(“Req_x0020_is_x0020_MNPI”)) {
      data.Req_x0020_is_x0020_MNPI = 1;
      }
      if (getFieldValue(“Req_x0020_Reg_x0020_Requirement”)) {
      data.Req_x0020_Reg_x0020_Requirement = 1;
      }
      if (getFieldValue(“Req_x0020__x002d__x0020_External”)) {
      data.Req_x0020__x002d__x0020_External = 1;
      }

      data.Req_x0020_Domain = getFieldValue(“Req_x0020_Domain”);
      data.Req_x0020_By = getFieldValue(“Req_x0020_By”);
      }

      newItem = spjs.utility.addItem({“listName”:_spPageContextInfo.pageListId,”data”:data});
      if(newItem.success){
      url = “http://sp-na.ms.com/GWM/PCELD_Deliverable/eagledatagov/Lists/Request/EditForm.aspx?ID=”+newItem.id;
      if(GetUrlKeyValue(“IsDlg”)===”1″){
      url += “&IsDlg=1”;
      }
      location.href = url;
      }else{
      alert(newItem.errorText);
      }
      }
      }

    • #36549
      Alexander Bautz
      Keymaster

      The problem is the lookup columns. When you use getFieldValue you only get the label, but when setting the value with code you must have the itemId.

      Change it like this:

      data.Source_x0020_Entity = jQuery("#dffs_Source_x0020_Entity option:selected").val();
      

      Alexander

    • #36550
      DougMcCourt
      Participant

      Hi Alexander – thank you so much – fixed it 100%
      Best – Doug McCourt

Viewing 2 reply threads
  • You must be logged in to reply to this topic.