Setting variable to NOW() and then using variable in Patch command

  • Setting variable to NOW() and then using variable in Patch command

    Posted by lisa-white on April 21, 2022 at 3:53 pm
    • Lisa White

      Member

      April 21, 2022 at 3:53 PM

      I have a Power App that uses parent and child SharePoint lists.

      In the child list (CRSP-Workflow), there is a Status drop-down field. If the user selects “Complete,” I need to update the Completion Date field in the parent list (CRSP-Main), which is a DateTime column in the SharePoint list.

      Here’s what I’ve tried.

      In child list form (frmWorkflow):

      • Dropdown is NewStatus (DataCardValue28).
      • In OnChange property of DataCardValue28, I want it to set variable only if the user selects Complete. Otherwise, do nothing. I have tried all of these:
        • If(“Complete” in DataCardValue28.SelectedItems.Value, Set(varCompletionDate, (Now())))
        • If(“Complete” in DataCardValue28.SelectedItems.Value, Set(varCompletionDate, Text((Now()))))
        • If(“Complete” in DataCardValue28.SelectedItems.Value, Set(varCompletionDate, DateTimeValue((Now()))))
      • I have a label on the form containing the variable – with all of these commands, the variable looks correct:

      Here’s the Patch command in the OnSuccess of frmWorkflow:

      If(
      !IsBlank(varCompletionDate),
      Patch
      (
      ‘CRSP-Main’,varRecord,
      {‘Date Completed’: {Value:varCompletionDate}
      }
      )
      );

      This is the error message:


      I read somewhere (which of course I can’t find again) that Now() is a record.

      Can anyone help me with this?

      Thanks.

      ——————————
      Lisa White
      Senior IT Specialist
      Herndon VA
      703-709-7172
      ——————————

    • Koen Mathijs

      Member

      April 22, 2022 at 5:09 AM

      Hi Lisa,

      please try to use the Now() function directly in your Patch statement instead of having it in a variable.
      You could try something like this:

      if(
      “Complete” in DataCardValue28.SelectedItems.Value,
      Patch(
      ‘CRSP-Main’,varRecord,
      {‘Date Completed’: Now()
      }
      )
      )

      Let us know if this works or not

      ——————————
      Koen Mathijs
      ——————————
      ——————————————-

    • Lisa White

      Member

      April 25, 2022 at 11:06 AM

      Thanks, Koen. That worked! Here’s the new code:

      If(
      varCompleted =”Yes”,
      Patch
      (
      ‘CRSP-Main’,varRecord,
      {‘Date Completed’: Now()
      }
      ),
      Patch
      (
      ‘CRSP-Main’,varRecord,
      {‘Date Completed’: Blank()}
      )
      )

      ——————————
      Lisa White
      Senior IT Specialist
      Herndon VA
      703-709-7172
      ——————————
      ——————————————-

    lisa-white replied 3 years, 5 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

The discussion ‘Setting variable to NOW() and then using variable in Patch command’ is closed to new replies.

Start of Discussion
0 of 0 replies June 2018
Now

Welcome to our new site!

Here you will find a wealth of information created for peopleĀ  that are on a mission to redefine business models with cloud techinologies, AI, automation, low code / no code applications, data, security & more to compete in the Acceleration Economy!