Please wait, loading...

 

formContext.data.process.getActiveStage.getNavigationBehavior is not a function for getNavigationBehavior

June 7, 2020

Object is used: An object with the allowCreateNew property that lets you define whether the Create button will be available in a stage so that user can create an instance of entityB from the entityA form in a cross-entity business process flow navigation scenario.

https://i0.wp.com/microsoftdynamics.in/wp-content/uploads/2020/06/img_5edcef1b7c001.png?fit=1703%2C730&ssl=1

For example, here is the Create button in the Develop stage of the AccountToContactProcess sample business process flow that lets you create a Contact record from the Account form.

Below snippet is from Microsoft doc which needs some correction:
https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/formcontext-data-process/stage/getnavigationbehavior

function sampleFunction(executionContext) {
    var formContext = executionContext.getFormContext();
    formContext.data.process.getActiveStage().getNavigationBehavior().allowCreateNew = function () {
        if (formContext.data.process.getName() === 'Test Process') {
            return false; // Create button is not available
        }
        else {
            return true; // Create button is available
        }
    }
}

When I used provided snippet it gave Error : formContext.data.process.getActiveStage.getNavigationBehavior is not a function ( This issue was raised y Mr johnnylawson on forums)

Instead of  “formContext.data.process.getActiveStage.getNavigationBehavior()” try using “formContext.data.process.getActiveStage().getNavigationBehavior()”

https://i0.wp.com/microsoftdynamics.in/wp-content/uploads/2020/04/Microsoftdynamics365.png?fit=640%2C651&ssl=1
Microsoft Dynamics Community Profile

Learn more