Announcements
I need to send formcontext to myFunction. The below line is called on OnLoad method.
formContext.data.process.addOnStageChange(myFunction);
*This post is locked for comments
Hello there!
The execution context is automatically passed as the first parameter to the function, So you dont need to worry about that. Are you getting any error?
have a look : docs.microsoft.com/.../addonstagechange
Try with this -
//Register below function in Onload and pass execution context from event handler function Onload(executionContext) { var formContext = executionContext.getFormContext(); formContext.data.process.addOnStageChange(myFunction); }
i am asking on how to pass executionContext to myFunction().
Assuming myfuction has the capbility to take formcontext as first param.
I have tried the following.
function myFunction(formcontext)
{
formcontext.ui.process.setDisplayState("collapsed"); --->this is where i m getting error process is undefined
}
can you please post the full code.you are passing the formContext - but code woundnt know from where formContext is coming.rather you pass executionContext in the function and then do something like executionContext.getFormContext()
Refer to Goutam's code above.
This line is missing in your code-
var formContext = executionContext.getFormContext();
See my code posted above.
Hello miss,
Kindly note the highlighted check box
function onload(executionContext)--->called this on form onLoad and is enabled and passed execContext first param
var formContext=executionContext.getFormContext();
function myFunction()
Xrm.Page.ui.process.setDisplayState("collapsed");// I want to change this to formContext.process but for that i need to pass either execution context or formcontext to myFunction
formContext.data.process.addOnStageChange(myFunction(formContext));
function myFunction(formContext) // Pass it as a parameter
formContext.process.setDisplayState("collapsed");
Hi Miss Dynamics
When you want to pass parameters to a function that is used as a parameter in another function call you can utilize the Anonymous function declaration and call myFunction like this:
var formContext = executionContext.getFormContext(); formContext.data.process.addOnStageChange(function() { myFunction(formContext); });
The anonymous function is sent as the parameter for addOnStageChange and inside it you have the option of doing whatever you want which in this case means calling your own function with parameters.
Well understood the issue and great answer. Thanks Daniel Wikell for the answer and Miss Dynamics for the question.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
Jump in, show your community spirit, and win prizes!
Expanding mentorship, skilling, and AI innovation
These are the community rock stars!
Stay up to date on forum activity by subscribing.