admin管理员组文章数量:1026986
I need to access a control of a web resource to refresh it. According to the link below we need to have the form context.
But I am unable to get the form context and couldn't find it anywhere in the documentation on how to access the execution context in the HTML web resources. I have tried registering a function on load of the form and passing execution parameter in it using form properties. Then in the function I am getting it like below with formContext variable as a global variable.
var formContext;
function getFormExecutionContext(executionContext) {
formContext = executionContext.getFormContext();
console.log("Form Context: ");
console.dir(formContext);
}
However when I tried to access this formContext in other HTML web resource placed on CRM form, it says undefined. Can someone please explain how can we get the form context in HTML web resource?
I need to access a control of a web resource to refresh it. According to the link below we need to have the form context.
But I am unable to get the form context and couldn't find it anywhere in the documentation on how to access the execution context in the HTML web resources. I have tried registering a function on load of the form and passing execution parameter in it using form properties. Then in the function I am getting it like below with formContext variable as a global variable.
var formContext;
function getFormExecutionContext(executionContext) {
formContext = executionContext.getFormContext();
console.log("Form Context: ");
console.dir(formContext);
}
However when I tried to access this formContext in other HTML web resource placed on CRM form, it says undefined. Can someone please explain how can we get the form context in HTML web resource?
Share Improve this question edited Jul 16, 2018 at 2:10 Arun Vinoth PrecogTechnologies 22.9k17 gold badges64 silver badges181 bronze badges asked Jan 10, 2018 at 13:46 Bilal HussainBilal Hussain 1915 silver badges19 bronze badges2 Answers
Reset to default 2Normally we will include the below snippet in HTML webresource head section, this will present you the CRM context & controls outside CRM form.
<head>
<title>HTML Web Resource</title>
<script src="../ClientGlobalContext.js.aspx" type="text/javascript" ></script>
</head>
Then access the controls like following:
parent.Xrm.Page.getAttribute("my_control").getValue();
The same should work in v9 as well for backward patibility, may be not mentioned in documentation.
In case your ribbon button is on subgrid and there you need to access FormContext in version 9.0 or after, here is the detail.
In Ribbon part, pass the below parameter.
<Actions>
<JavaScriptFunction FunctionName="subgridEvent" Library="$webresource:new_contactformload.js">
<CrmParameter Value="PrimaryControl" />
</JavaScriptFunction>
</Actions>
And here is the function to access the Form Context.
function ribbonHandler(e) {
var formContext = e.getFormContext();
var recordId = formContext.data.entity.getId();
var fieldValue = formContext.getAttribute("<field_name>").getValue();
}
Here is the Reference which saved my time.
I need to access a control of a web resource to refresh it. According to the link below we need to have the form context.
But I am unable to get the form context and couldn't find it anywhere in the documentation on how to access the execution context in the HTML web resources. I have tried registering a function on load of the form and passing execution parameter in it using form properties. Then in the function I am getting it like below with formContext variable as a global variable.
var formContext;
function getFormExecutionContext(executionContext) {
formContext = executionContext.getFormContext();
console.log("Form Context: ");
console.dir(formContext);
}
However when I tried to access this formContext in other HTML web resource placed on CRM form, it says undefined. Can someone please explain how can we get the form context in HTML web resource?
I need to access a control of a web resource to refresh it. According to the link below we need to have the form context.
But I am unable to get the form context and couldn't find it anywhere in the documentation on how to access the execution context in the HTML web resources. I have tried registering a function on load of the form and passing execution parameter in it using form properties. Then in the function I am getting it like below with formContext variable as a global variable.
var formContext;
function getFormExecutionContext(executionContext) {
formContext = executionContext.getFormContext();
console.log("Form Context: ");
console.dir(formContext);
}
However when I tried to access this formContext in other HTML web resource placed on CRM form, it says undefined. Can someone please explain how can we get the form context in HTML web resource?
Share Improve this question edited Jul 16, 2018 at 2:10 Arun Vinoth PrecogTechnologies 22.9k17 gold badges64 silver badges181 bronze badges asked Jan 10, 2018 at 13:46 Bilal HussainBilal Hussain 1915 silver badges19 bronze badges2 Answers
Reset to default 2Normally we will include the below snippet in HTML webresource head section, this will present you the CRM context & controls outside CRM form.
<head>
<title>HTML Web Resource</title>
<script src="../ClientGlobalContext.js.aspx" type="text/javascript" ></script>
</head>
Then access the controls like following:
parent.Xrm.Page.getAttribute("my_control").getValue();
The same should work in v9 as well for backward patibility, may be not mentioned in documentation.
In case your ribbon button is on subgrid and there you need to access FormContext in version 9.0 or after, here is the detail.
In Ribbon part, pass the below parameter.
<Actions>
<JavaScriptFunction FunctionName="subgridEvent" Library="$webresource:new_contactformload.js">
<CrmParameter Value="PrimaryControl" />
</JavaScriptFunction>
</Actions>
And here is the function to access the Form Context.
function ribbonHandler(e) {
var formContext = e.getFormContext();
var recordId = formContext.data.entity.getId();
var fieldValue = formContext.getAttribute("<field_name>").getValue();
}
Here is the Reference which saved my time.
本文标签: javascriptForm Context in Dynamics 365 version 9Stack Overflow
版权声明:本文标题:javascript - Form Context in Dynamics 365 version 9 - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745640544a2160718.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论