Passing parameters to JavaScript is possible in Dynamics 365. When calling a particular method, we can see a way to pass whatever the parameters as below, apart from execution context as below.
{ "type": "external", "isTaxInclude": true, "industryCode": 500, "profile": { "authority": "ABC Corp", "proficencyLevel": "Advanced", "jobCodes": [ "GGG11", "ABX00", "XXY87" ], "noOfContractors":120 } }
If you go to debug (ad text debugger; to the code and perform operation after pressing F12) mode you will see how easy to access the different attributes with the JavaScript. Check how I see it once above Json object is passed;
If you are working with much complex Json objects, JsonPathFinder or JSONPath Finder chrome extension can help you sort the different values.
Passing parameters to JavaScript like this is particularly useful in below scenarios;
1) Same script to be used in different Forms with different parameters
2) Same script to be used in different Entities with different parameters
Anyway, one thing to keep in mind is these parameters can't be different in different environments. This is because, if a Solution is deployed with same Form, these parameters are being overridden with what is in the Solution. In other terms, this technique is NOT suitable to keep environmental specific variables.
One way to keep environmental variables is by checking the URL to determine the environment and load the variable accordingly.
No comments:
Post a Comment