简体   繁体   中英

How to get Dynamics CRM Web Resource name using JavaScript

I'm working on a project. I want to get the name of web resource eg if I want to get entity name I use this query

var entityName = parent.Xrm.Page.data.entity.getEntityName();
var id = parent.Xrm.Page.data.entity.getId();

so in the same way how I can get the web resource name at this time, I am passing the web resource as a string.

getImages(entityName, id, "WebResource_webTest");

So can you tell me how i can get the web resoucre name.

Here is the code snippet I just tried on one of my Entity and it gave me webresource name

You can add this function on load on change and pass execution context as parameter to function

Note: If you have 5 webresources on your form you will get one by one all the webresource names. you can tweak/modify code as per your need.

function onChangeOfField(executionContext) {
    debugger
    var formContext = executionContext.getFormContext();
 formContext.ui.controls.forEach(function(control, index) {
            var controlType = control.getControlType();
            if (controlType === "webresource" ) {
               alert(control.getName());
            }               
    });
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM