Need to set null lookup value through the Power Pages web API, and your copilot does not know how to do it, yet?

By | September 13, 2024

Let’s say you are trying to use Power Pages web api to set a lookup column to null.

You might want to ask copilot, but, depending on which one you ask (maybe none of them?), it might not know, not yet at least:

Well, normally, you’d be using this syntax to prepare your data object for the ajax webapi call:

data[“[email protected]”] = “/ita_tablenames(” + value + “)”;

This would not work for nulls, though, and this would not work either:

data[“[email protected]”] = null;

Instead, you need this:

data[“ita_TableName”] = null;

So your code would look more or less like this:

if(value){
   data["[email protected]"] = "/ita_tablenames(" + value + ")";
}
else{
   data["ita_TableName"] = null;
}

Leave a Reply

Your email address will not be published. Required fields are marked *