Can we use Xrm.Utility.getGlobalContext().getQueryStringParameters() instead of Xrm.Page.context.getQueryStringParameters() in CRM v9.0?
*This post is locked for comments
Can we use Xrm.Utility.getGlobalContext().getQueryStringParameters() instead of Xrm.Page.context.getQueryStringParameters() in CRM v9.0?
*This post is locked for comments
Even though I couldn't find official documentation, you can use Xrm.Utility.getGlobalContext().getQueryStringParameters() to pass the custom parameters.
Here's the sample code.
//Code from the parent form which is opening quick create form var entityFormOptions = {}; entityFormOptions["entityName"] = "contact"; entityFormOptions["useQuickCreateForm"] = true; var formParameters = {}; formParameters["firstname"] = "Sample"; formParameters["lastname"] = "Contact"; formParameters["description"] = formContext.getAttribute("description").getValue(); formParameters["test_parameter"] = "Test parameter from main form"; Xrm.Navigation.openForm(entityFormOptions, formParameters); //OnLoad of Quick Create form to access the custom parameter from the parent form var queryString = Xrm.Utility.getGlobalContext().getQueryStringParameters(); if (queryString["test_parameter"] !== null) { Xrm.Navigation.openAlertDialog( { text: queryString["test_parameter"] }, null); }
Refer the below sample code to read custom parameter tabname (string).
if(formContext.data.attributes){
if(formContext.data.attributes.get("parameter_tabname")){
var tabname = formContext.data.attributes.get("parameter_tabname").getValue();
if(tabname!=null && tabname!=""){
console.log(tabname);
}
}
}
Try using formContext.data.attributes to get the query string parameters in D365 v9 forms/entities.
Thank you HIMBAP!
We tried Xrm.Page.context.getQueryStringParameters() to get query string parameters on html page and we are getting result which we were looking for. But in Unified Interface we are not getting results by using Xrm.Page.context.getQueryStringParameters() and we also tried window.location.search, however we are not getting result in UCI which we want. Can you advise how I can get query parameters in UCI?
Thanks in advance!
Ohh if you are working with html then using Xrm.Utility's one should be good.
Thanks
Thanks for reply !
But we are opening html web resource on application ribbon button click. On that page we are using above part. What we can use to get querystringparameteres on html page when opening from application ribbon button?
Earlier we were using Xrm.Page.context.getQueryStringParameters(). We found the replacement for that is Xrm.Utility.getGlobalContext().getQueryStringParameters() to get querystringparameteters for CRM9.0. Can we use the same in CRM 9.0?
Based on the documentation there is no getQueryStringParameters anymore.
The getQueryStringParameters has been replaced by formContext.data.attributes:
The formContext.data.attributes API will make retrieval of non-entity bound data consistent across entity forms, metadata-driven dialogs, and task-based flows. The data will be a combination of custom values sent using the query string and what was specified in the parameters in the openForm method.
See deprecated client api functions:
docs.microsoft.com/.../important-changes-coming
Hope this helps.
Hi,
You can try this:
var formContext=executionContext.getFormContext();
var queryStringParameters=formContext.context.getQueryStringParameters();
Thanks
André Arnaud de Cal...
292,489
Super User 2025 Season 1
Martin Dráb
231,305
Most Valuable Professional
nmaenpaa
101,156