When using Flow to copy a item in a Sharepoint LIst to another SHareoint List, I am running into problems handling Lookup Fields.
If the source Sharepoint Item has a Lookup field and its empty (null) and you try to create a new item from this source the Flow will throw an error because FLow (much like SHarepoint Designer in the past) can not hanlde setting a Lookup field to Null.
I would like to know if there is way using expressions that I can test the input field (from the source item) for null and then do nothing to avoid the error thrown. I know I can instead use a text field in the target and set it to the Lookup field value and that is one solution but not the best one.
This is a really simple Flow that archives items from one Sharepoint List into another but there are multiple lookup fields and all of them can be empty -- actually FLow should be able to hanlde setting a lookup field to null but if I could use an IF expression that tests for null that might be a reasonable workaround
Hello
Just stucked in the same issue and get it solved by passing ID=0 while the source item lookup field is null
In this case, the copied item will be created with an empty lookup value.
I just use a condition If(empty(yoursourcelookupfield,null),0,yoursourcelookupfield)
Of course except I want to create an item for both conditions so this would be doable by adding another Create Item Action for the other branch and not include the Lookup column in that branch.
But this does not solve the problem as we have lists that have 3, 4 or even 5 lookup columns so with 4 lookup columns the logic complexity becomes amazingly complex with so many combinations of possibilities. What I really need is to able to put an Expression in the Create Item lookup column that will do nothing if the input is null and use the value if it is not null -- there appears to be no way to do that. WIth that capability I can have many lookup columns and I don't need any complex set of conditions with multiple Create Item actions.
Seem pretty straightforward to me and your solution really only works realistically if there is ONLY one lookup column that could be null -- its really unacceptable if there are multiple lookup columns any one of which could be null.
Hi @ SPMP,
I have made a test on my side and please refer to the screenshot of my flow as below:
Note:
@empty(triggerBody()?['lookup_x0020_repairshop'])
When an item is created in the “report” list, and the “lookup repairshop” column is null, the flow would run successfully as below:
When an item is created in the “report” list, and the “lookup repairshop” column is not null, the flow would run successfully as below:
Regards,
Alice Zhang
WarrenBelz
146,660
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,004
Most Valuable Professional