Показать сообщение отдельно
Старый 13.11.2018, 03:30   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
powerobjects: Using Form Save with Custom Web Resources
Источник: https://www.powerobjects.com/2018/11...web-resources/
==============


Microsoft has provided plenty of tools for use when out-of-the-box customizations fall short. Using custom web resources on forms can be a powerful tool, but it should integrate seamlessly with the form. To accomplish this, the web resource can hook onto the save of the form. This provides an easy way for users to interact across the different parts of the form without having to worry about multiple toolbars. In today’s blog, we’ll show you how it’s done!

Let’s say we have a web resource that surfaces information from a different entity, or a different source all together, and allows user input. In just a few simple steps, we can save any data we need from the web resource at the same time as the form.

1. Retrieve initial modifiedon information:

var modifiedon = parent.Xrm.Page.getAttribute(“modifiedon”).getValue();

2. Set up callbacks:

parent.Xrm.Page.data.entity.addOnSave(function(context){

    //Trigger any necessary calls here

});

parent.Xrm.Page.getAttribute(“modifiedon”).addOnChange(function(context){

    modifiedOn = context.getFormContext().getAttribute(“modifiedon”).getValue();

});

3. Set modifiedon based on user interaction in the web resource:

If(WebResource Needs To Save){

    Xrm.Page.getAttribute(“modifiedon”).setValue(new Date());

}

else{

    Xrm.Page.getAttribute(“modifiedon”).setValue(modifiedOn);

}

While the user interacts with the web resource, it is setting the modifiedon field to either the saved date or a new date. This will make the form appear dirty whenever the web resource requires a save, or other function call, to happen. Users will no longer know they are interacting with a separate web resource.

We hope this comes in handy for you. For more tips and tricks – be sure to check out our blog!

Happy D365’ing!



Источник: https://www.powerobjects.com/2018/11...web-resources/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.