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
Solution Supplier
Solution Supplier

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.

View solution in original post

Helpful resources

Announcements
User Groups Public Preview

Join us for our User Group Public Preview!

Power Apps User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (64,388)