cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RStanley
Regular Visitor

Need help with pushing user information to CDS on Checkbox click and removing date information when checkbox is unclicked

Here is my formula:


If(
Checkbox1.Value=true,
Patch('AtNeed Complete v2S', ThisItem, {'Task Completed - Sales Followup':"Yes", 'Task Completed - Sales Date':Today(), 'Task Completed - Sales Associate':User()}),
Patch('AtNeed Complete v2S', ThisItem, {'Task Completed - Sales Followup': "", 'Task Completed - Sales Date':"", 'Task Completed - Sales Associate':""})
)

 

 

Here is what I would like to do when a user clicks Checkbox1:


*Set CDS field 'Task Completed - Sales Followup' to Yes


*Set CDS field 'Task Completed - Sales Date' to Today


*Set CDS field 'Task Completed - Sales Associate' to the user that clicked the box.  

 


I can accomplish the first two, but cannot get the user recorded. 
I get the following three errors:

Invalid argument type. 
Expecting a Record value, but of a different schema.


Missing column.  Your formula is missing a column 'Access Mode' with a type of 'OptionSetValue'.


The function 'Patch' has some invalid arguments.


In CDS, the field 'Task Completed - Sales Associate' is set as a Data type of Lookup and Related entity of User.

 

 

Here is what I would like to when a user unclicks Checkbox1:


*Clear CDS field 'Task Completed - Sales Followup' 


*Clear CDS field 'Task Completed - Sales Date' 


*Clear CDS field 'Task Completed - Sales Associate' 


The only one of these tasks I've been successful with is the first.  

 

 

Can someone help me with entering the user information and clearing the date?

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @RStanley ,

Since lookup field is a complex data type, you need a little special formula to update it.

I suggest you try this formula:

Patch('AtNeed Complete v2S', ThisItem, {'Task Completed - Sales Followup':"Yes", 
'Task Completed - Sales Date':Today(),
'Task Completed - Sales Associate':
LookUp(Users,'Full Name'=User().FullName)})

Here's a  issue about how to update lookup data type of cds in powerapps for your reference:

https://powerusers.microsoft.com/t5/Building-PowerApps-Formerly/Patch-a-CDS-Lookup-column-within-Pow...

The second thing that you want to, I'm afraid it's not supported in PowerApps currently.

Because "" is text type, while the three columns that you want to update to blank are all not text type.

However, there's an alternative way to make this, please refer this issue:

https://powerusers.microsoft.com/t5/Building-PowerApps-Formerly/Update-blank-Null-value-to-fields-Da...

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Edwin-Abdalian
Impactful Individual
Impactful Individual

what is the type of the 'Task Completed - Sales Associate' field? is it a lookup field to the Users entity? also I noticed that you are setting that field to User(). the User() function returns a record and you can't patch it to a single column. Try using User().Email or User().FullName

v-yutliu-msft
Community Support
Community Support

Hi @RStanley ,

Since lookup field is a complex data type, you need a little special formula to update it.

I suggest you try this formula:

Patch('AtNeed Complete v2S', ThisItem, {'Task Completed - Sales Followup':"Yes", 
'Task Completed - Sales Date':Today(),
'Task Completed - Sales Associate':
LookUp(Users,'Full Name'=User().FullName)})

Here's a  issue about how to update lookup data type of cds in powerapps for your reference:

https://powerusers.microsoft.com/t5/Building-PowerApps-Formerly/Patch-a-CDS-Lookup-column-within-Pow...

The second thing that you want to, I'm afraid it's not supported in PowerApps currently.

Because "" is text type, while the three columns that you want to update to blank are all not text type.

However, there's an alternative way to make this, please refer this issue:

https://powerusers.microsoft.com/t5/Building-PowerApps-Formerly/Update-blank-Null-value-to-fields-Da...

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,923)