Bhubaneswar, Odisha, India
+91-8328865778
support@softchief.com

With function in PowerFX Canvas App

With function in PowerFX Canvas App

In Canvas App PowerFX, you can use with function to define variables with a limited scope. Without using Local or Global variable or Collection Variable, you can scoped variables using WITH function.

Here sample PowerFX mentioned using variables and corresponding with function.

Scenario : Extract all accounts with name MS and update all records with name TEST.

Using Variable :

Set(
    targetRecord,
    Filter(
        Accounts,
        'Account Name' = "MS"
    )
);
ForAll(
    targetRecord,
    Patch(
        Accounts,
        ThisRecord,
        {'Account Name': "TEST"}
    )
)

Using Collection Variable:

ClearCollect(
    colRecords,
    Filter(
        Accounts,
        'Account Name' = "TEST"
    )
);
ForAll(
    colRecords,
    Patch(
        Accounts,
        ThisRecord,
        {'Account Name': "MS"}
    )
)

Using WITH function:

With (
    {
        TargetRec: Filter(
            Accounts,
            'Account Name' = "MS"
        )
    },
    ForAll(
        TargetRec,
        Patch(
            Accounts,
            ThisRecord,
            {'Account Name': "TEST"}
        )
    )
)

Hope this helps.