I have a bunch of If checks at a form submission to determine if fields have been modified. I'm sure there are better ways to do this but I have this working for all but one field which is a choice field. I cannot for the life of me figure out how to do the comparison.
Here is my code (I know it's currently wrong. I can't compare a text string to a record but removing the .DisplayName on the left to compare records fails. And I can't use .DisplayName on the datacard default which is also referencing a user from a choice list.
If(
DataCardValue12.Selected.DisplayName <> crdAssignedUser2.Default, // Check if the Assigned To has been changed
Patch(
ActEntry, // Specify the target data source (ActEntry table)
Defaults(ActEntry), // Create a new record
{
TicketNumber: RequestID, // Use the same TicketID formula the Details Form does
Activity: "Assigned",
Entry: DataCardValue12.Selected.DisplayName, // Write the new value of the Assigned To
Datetime: Now(),
User: User().FullName
}
)
);
DataCardValue12.Selected <> crdAssignedUser2.Default doesn't work. This one doesn't show an error on either side but it shows error at the <>.
DataCardValue12.Selected.DisplayName <> crdAssignedUser2.Default.DisplayName doesn't work. The right side shows an error for .DisplayName. Although that Default is a record that does resolve to a user, I can't get 'inside' the record to do the comparison here.
Thank you. This works:
If( DataCardValue12.Selected.Email <> LookUp(Tickets, ID = varItem, AssignedUser).Email,
@DCHammer haha it’s all good. We all have been in the same boat.
I meant to say replace <FormItemProperty> with the code that is in Item property of the Form. Sorry I wasn’t very clear.
I'm not clear on what belongs in the <FormItemProperty>. It's often amazing to me how long it takes me to figure out what should be a simple value comparison. Makes me question my own sanity. 😉
That doesn't work. It compares a text string to a record. Appreciate the assist though.
try with below -
!(DataCardValue12.Selected.DisplayName = crdAssignedUser2.Default)
@DCHammer To check if any fields in a Form were modified, you can use Form.Unsaved function which will give you a boolean value.
If people picket is not a multi-choice field, then to compare the value in Form to the value in the database try this:
DataCartValue12.Selected.Email <> <FormItemProperty>.<ColumnName>.Email
WarrenBelz
146,605
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,946
Most Valuable Professional