Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1850
  • Last Modified:

CRM 2011 - Reference Javascript Web Resource from another Javascript Web Resource

I have download a XrmServiceToolkit.js and create a Web resource called XrmServices.
I would like to call the function of XrmService within another JavaScript Web Resource?
Can it be done? Or any reference you can suggest for a step by step how to do this.  Thanks.
0
tommym121
Asked:
tommym121
  • 2
  • 2
2 Solutions
 
Chinmay PatelEnterprise ArchitectCommented:
Hi tommym121,

It can be easily done.

First, refer to this article : http://blogs.msdn.com/b/lezamax/archive/2010/10/21/crm-2011-web-resources-simulating-directories-and-the-importance-of-relative-paths.aspx

Basically all you need to do is refer to XrmServiceToolkit's features in your scripts and html files and make sure that on the form where you call your web resource, xrmservicetoolkit.js is also available.

Just make sure that you use $webresource directive so that you can always track component dependencies.

Regards,
Chinmay.
0
 
tommym121Author Commented:
Chinmay,

I am not 100% sure what I need to do.  I have created the web resource for XrmServiceSdk.
It has a function to retrieve the field value by calling XrmServiceSdk,GetFieldValue('LogicalName')
What I am trying to create another function (not in XrmServiceSdk Web Resource but rather another Web resource) that will combine the values from FirstName and LastName.  Something like below
Function combineFieldsValue (val1, val2)
{
       combineFieldsValue = val1 + ' ' + val2;
}
This function will be call in the OnChange event of a field in the form.

Can I do that?  Or I really have to add a function into the XrmServiceSdk since Javascript do not allow #include type.

Hope you can clear up my confusion.  Thanks.
0
 
Chinmay PatelEnterprise ArchitectCommented:
Hi tommym121,


Sure. Basically, you call this function as if it is already available to you.
Just on the form where you add your script libraries, make sure to add XrmServiceSDK's js also.

Regards,
Chinmay.
0
 
tommym121Author Commented:
Thanks
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now