Change Record Status in Power Apps using Power Fx

 We want to change the status of a class record to "Inactive" when all courses associated with the class are completed by every participant.

Power Apps Implementation:

  1. Check Completion:

    • First, we determine if all courses for all participants are complete using a variable named allCoursesComplete. This variable should be set based on your specific logic, which typically involves checking if there are any courses still marked as incomplete.
  2. Update the Class Record:

    • Using Power Apps, we can update the class status directly within the application when all courses are confirmed complete. Here is a simple and effective way to do this:
If(
    allCoursesComplete,
    Patch(
        Classes,
        LookUp(Classes, Session = GUID(passedClassId)),
        {statecode: 'Status (Classes)'.Inactive}
    )
)


  • If Function: This checks if allCoursesComplete is true.
  • Patch Function: This updates the data source for class records, Classes.
  • LookUp Function: This identifies the specific class by its session ID, ensuring we target the correct record.
  • {statecode: 'Status (Classes)'.Inactive}: This sets the statecode field to "Inactive". This syntax directly references the OptionSet value for "Inactive" within the Classes data source.

No comments:

Post a Comment