I need to do null value handling for setting sharepoint list column. So, I am using ternary operator for same. I am using client object model(jQuery/sp.js)

myVar == null ? "" : myVar

In browser when I see column value it come blank space but when I viewing value using rest end point

field value is coming null

"UserCity": null,

Instead, I want

  • can you share some more code/description ...... Because there is nothing wrong with your ternary operator.. – Rohit Waghela Jan 8 '18 at 11:24
  • @RohitWaghela I am using code from MSDN site only msdn.microsoft.com/en-us/library/office/… during debugging I found it is setting as oListItem.set_item('UserCity', ""'); – Pawan Kotak Jan 8 '18 at 11:39
  • What is the column type for which you need null handling – Sunil Sahu Jan 8 '18 at 13:30
  • @sunilsahu single line of text – Pawan Kotak Jan 8 '18 at 15:40

Hi to assign value handling null you can use "Conditional assertion"

myVar = myVar || "";

And i don't think so it might be giving you null infact it be like

<UserCity m:null="true" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.