I am creating a timer application for Microsoft CRM. I created the application as a web resource already and it works. It uses CRM's XRM client-side code to do the work. It needs to update data in a custom entity within CRM. However requirements for the timer application have changed and it now needs to stay active even if the user navigates away from the page. So it needs to open on the incident form, but then the user could navigate anywhere else in CRM and it needs to stay open and actively tracking time.
My first thought was to just pop the web resource into a new and separate window on the button click and have it run independently. However, if the code is embedded inside a web resource in the form, if they navigate away won't the code get unloaded?
I have only been working with Microsoft CRM for a few months, so I probably don't know all the options.
So the specific question:
Is it possible to open up a stand-alone web resource in a new window that stays active when they navigate away from the form and still have access to the XRM client library? (if so, how?)
If the answer is no, then I'd love to hear alternative ideas.
Thank You.
To solve this scenario I used 2 web resources. One on the form that has a custom button to gather required case information and send it to the second web resource:
// Collect fields we know exist at this point, because they are required fields on the case
var caseId = window.parent.Xrm.Page.data.entity.getId();
if (caseId != '') {
var caseName = window.parent.Xrm.Page.data.entity.getPrimaryAttributeValue();
var accountId = window.parent.Xrm.Page.getAttribute("customerid").getValue()[0].id;
var accountName = window.parent.Xrm.Page.getAttribute("customerid").getValue()[0].name;
// package paramters to pass to timer web resource
var customParameters = encodeURIComponent("caseid=" + caseId + "&casename=" + caseName + "&accountid=" + accountId + "&accountname=" + accountName);
// Open web resource
window.parent.Xrm.Utility.openWebResource("sp_casetimer", customParameters, 500, 200);
} else {
// Error message would go here - case must be saved first.
}
The sp_casetimer web resource then parses and stores the variables into hidden fields and can function independently. I use the /XRMServices/2011/OrganizationData.svc to then do CRUD operations on my custom case time entity.