cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AnonyMouse
Level: Powered On

Clear DateField and Lookup Column value

I have a datefield and lookup column in my form. In the EditForm, after the user clears the datefield column and lookup column to an empty value and save the form, in sharepoint, it still retains the old value. How can I set these fields back to null?

1 ACCEPTED SOLUTION

Accepted Solutions
joshnystrom
Level 8

Re: Clear DateField and Lookup Column value

Okay, I've done more investigation on what is possible with this approach and here is a (hopefully) simple rollup:

You can reliably clear Person, Choice and Lookup (but still not Date) fields as follows:

Set each corresponding "blank" variable (Person is a Table, the others are individual Records)

Set(
    BlankPerson,
    Table(
        {
            Claims: Blank(),
            DisplayName: Blank(),
            Email: Blank(),
            Department: Blank(),
            Picture: Blank(),
            JobTitle: Blank()
        }
    )
);
Set(
    BlankChoice,
        {
            Id: -1,
            Value: Blank()
        }
);
Set(
    BlankLookup,
        {
            Id: -1,
            Value: Blank()
        }
)

And merge-patching the target list item like so:

Patch(
        'Test List',
        {ID: ItemID},
        {
	    PersonField: BlankPerson,
            ChoiceField: BlankChoice,
            LookupField: BlankLookup
        }
    )

That's all I have so far. I still haven't tested Groups but I suspect they would work fine.

Good luck!

Josh

11 REPLIES 11
Motz
Level: Power Up

Re: Clear DateField and Lookup Column value

One way to do it is to create a local variable using and set that to blank and make the default value for the date control to be the variable you created.

 

UpdateContext({BlankMe:Blank()})

 

Set DefaultDate for DatePicker1 to BlankMe.

 

Whenever you save the form, you'll reset the control.

 

Reset(DatePicker1)

AnonyMouse
Level: Powered On

Re: Clear DateField and Lookup Column value

Tried you suggestion. 

In the OnVisible, I set the variale, UpdateContext({BlankMe:Blank()})

In the default property of the datepicker, I set BlankMe

On submit of the button, I have Reset(DatePicker1);SubmitForm(EditForm)

 

But it does not clear the value from the Sharepoint list

Community Support Team
Community Support Team

Re: Clear DateField and Lookup Column value

Hi @AnonyMouse,

 

I can reproduce your issue. I will report this to pg and see if they have any suggestions.

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Shamprasadrh
Level: Powered On

Re: Clear DateField and Lookup Column value

I too have this issue, any solutions ?

systemcrash
Level: Powered On

Re: Clear DateField and Lookup Column value

It has been two weeks... any update on clearing Lookup Column value on SPL via PowerApps?

systemcrash
Level: Powered On

Re: Clear DateField and Lookup Column value

I thought this was a recent issue but it seems it has been over 7 months that the issue is still going without any solution.

I did few test to on a simple SPL with customized PA form. Where users clear their names from the Person field and save it back to the SPL.

I did try with Patch() and SubitForm().  Both I wasn't able to clear the Person field... or if you prefer to remove the value from that field and keep the value.

@v-monli-msft do you have any update?

I consider this as simple (basic) value assignation that should work properly... but it doesn't.

joshnystrom
Level 8

Re: Clear DateField and Lookup Column value

Hi all, I found a way to clear Person/People picker fields that doesn't rely on experimental features, nor a Flow, so I thought I'd surface it here. I'm not yet sure if the same approach will work for DateField, LookUp or Group Picker, but hopefully!

My current understanding of my approach makes a few assumptions (I'm not certain whether they are integral to its use):

-You are treating this like a "Complex" data update and are therefore using Patch statements to merge into the existing SP List item
-Your app has a way to detect when the person-picking control was left blank so that you can conditionally change which Patch statement is being executed

-You are using the out-of-the-box people picker or can otherwise tweak my approach to match a "valueless" Person record

All I've done is prep a "BlankPerson" variable that is manually shaped as a single, blanked-out Person record for the SP Person/Group field, as follows:

Set(BlankPerson,Table({'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",Claims:Blank(),DisplayName:Blank(),Email:Blank(),Department:Blank(),Picture:Blank(),JobTitle:Blank()}))

When Patching with this as my payload when the People picker control is left blank, I've been able to Clear the corresponding field on my SP List item.

 

Hope this helps someone!

Josh

 

 

E: In this thread - https://powerusers.microsoft.com/t5/General-Discussion/Clearing-out-people-picker-field/m-p/249368/h... - RandyHayes indicated that this approach is working for LookUp fields as well.

joshnystrom
Level 8

Re: Clear DateField and Lookup Column value

Okay, I've done more investigation on what is possible with this approach and here is a (hopefully) simple rollup:

You can reliably clear Person, Choice and Lookup (but still not Date) fields as follows:

Set each corresponding "blank" variable (Person is a Table, the others are individual Records)

Set(
    BlankPerson,
    Table(
        {
            Claims: Blank(),
            DisplayName: Blank(),
            Email: Blank(),
            Department: Blank(),
            Picture: Blank(),
            JobTitle: Blank()
        }
    )
);
Set(
    BlankChoice,
        {
            Id: -1,
            Value: Blank()
        }
);
Set(
    BlankLookup,
        {
            Id: -1,
            Value: Blank()
        }
)

And merge-patching the target list item like so:

Patch(
        'Test List',
        {ID: ItemID},
        {
	    PersonField: BlankPerson,
            ChoiceField: BlankChoice,
            LookupField: BlankLookup
        }
    )

That's all I have so far. I still haven't tested Groups but I suspect they would work fine.

Good luck!

Josh

oliverlpgmail
Level: Power Up

Re: Clear DateField and Lookup Column value

I tried to clear  a user field but the editor complained about it being a Record and not a Table.

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 185 members 4,051 guests
Please welcome our newest community members: