locked
Offline client scripts not running? RRS feed

  • Question

  • Hi everyone,

    I was under the impression that web resources where available while offline. When several offline users synced back to the system we had strange data...resulting from scripts not executing while offline. The scripts fire while using the online outlook client, but while offline they do not. Since the offline client uses a local web server, pulls down the customization and executes in a IFrame, I would believe that they would work. However, I remember alot of talk about Offline Plugins for 4.0; are they still needed with 2011? Thanks for any input.

    Richard D. James

     

     

     

    Tuesday, October 4, 2011 2:01 PM

Answers

  • It might help if you post some of the code that you implemented the business rules but didn't work while offline. 

    Speaking about the server URL, you will be safe if you have used getServerUrl() method instead of any hard-coded server URL. (EDIT: this was not correct, getServerUrl method always returns the CRM server URL, not the offline client web server URL, please see Richard's solution below)


    Daniel Cai | http://danielcai.blogspot.com
    Tuesday, October 4, 2011 8:41 PM

All replies

  • It should not be the case that web resources are not available while offline if the client has properly synced with the server before going offline. I think you might want to investigate the script code in the web resources and make sure that it uses the right server URL while offline if your implementation relies on CRM service calls. Also you should always validate your web resources against offline client if it is used in your deployment. 

    Offline plugin has not changed from CRM 4.0. If a plugin has not been specified to be used for offline deployment, the business logic that you have implemented in the plugin will not be triggered while your users are working offline. So yes, if you have any business logic implemented in plugin, you need to enable it for offline deployment in plugin registration tool. 


    Daniel Cai | http://danielcai.blogspot.com
    Tuesday, October 4, 2011 6:50 PM
  • Daniel,

    Thanks for the reply. I don't know if I mentioned it but the scripts work in the browser and in Outlook, but not offline. So I believe that the server URL would be correct. Or do I need to to check the script logic to see if the client is offline and if offline set a different server URL? I really don't know what the name of that server would be...? 

     

    RDJ

     

    Tuesday, October 4, 2011 8:37 PM
  • It might help if you post some of the code that you implemented the business rules but didn't work while offline. 

    Speaking about the server URL, you will be safe if you have used getServerUrl() method instead of any hard-coded server URL. (EDIT: this was not correct, getServerUrl method always returns the CRM server URL, not the offline client web server URL, please see Richard's solution below)


    Daniel Cai | http://danielcai.blogspot.com
    Tuesday, October 4, 2011 8:41 PM
  • I did find the issue. We used a FQDN for the server so we could disable script scanning. With that we were not getting the correct server name using getServerUrl() method, we got he FQDN name. We changed the script library to use the getOrgUniqueName(), so the offline client is not using the local server it is using the Organization Name which I don't believe is found..

     

    RDJ

    Wednesday, October 5, 2011 2:27 PM
  • Resolved the issue....I just change the endpoint if it is the outlook offline client.

    var boolOutlook = Xrm.Page.context.isOutlookClient();
    var boolOnline = Xrm.Page.context.isOutlookOnline();
    var ODATA_Final_url = orgName + ODATA_ENDPOINT + ODATA_EntityCollection + ODATA_Query + filter;
    if(boolOutlook){				
    	if(!boolOnline){					
    	ODATA_Final_url = serverUrl + ODATA_ENDPOINT + ODATA_EntityCollection + ODATA_Query + filter;	}				
    	}			
    


    Not the prettiest snippet but it is working. Thanks Daniel.

     

    RDJ

    Wednesday, October 5, 2011 3:33 PM
  • I should only take half of the credit. ;-) Your approach is the valid one.

    I was previously under the impression that getServerUrl method will always return the right server URL. That was not correct. 

    Thanks for the update. 


    Daniel Cai | http://danielcai.blogspot.com
    Wednesday, October 5, 2011 3:41 PM