Link to home
Start Free TrialLog in
Avatar of sbdt8631
sbdt8631

asked on

Dynamics CRM 4.0 Use JavaScript to retrieve data fields from an order

I am customizing the Case form and need to be able to retrieve the Ship Date, Invoice Number, Invoice Date and PO Number fields from an order based on the Order Number I retrieve via a custom lookup I created.  I need a JavaScript example I can copy and modify to obtain these values so I can dynamically populate these fields on my form.
Thanks.
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Hi sbdt8631,

Use CRM4 JavaScript Toolkit and the following blogpost:

http://danielcai.blogspot.in/2010/01/crm-web-service-javascript-toolkit.html

Regards,
Chinmay.
Avatar of sbdt8631
sbdt8631

ASKER

Chinmay_Patel

I am afraid I am lost.  I downloaded the attached file but I do not know what to do with it.  I looked under Documents on the codeplex site but there was not much there.  I tried creating an isv\CrmServiceToolkit folder and pasting in the contents of the toolkit file as it said to do in the blog, but that caused CRM as a whole to stop functioning.  I quickly removed it and all is ok. I modified the code from one of the examples and put it in my form, but was unsurprised when I got a CrmServiceToolkit is undefined error.  In his blog, under comments, Daniel says to copy the CrmServiceToolkit.js code into the OnLoad event but I do not have a CrmServiceToolkit.js file in the toolkit I downloaded.
What am I missing?  Are there instructions for implementing this anywhere?
XrmSvcToolkit-0-2-managed.zip
SOLUTION
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Chinmay_Patel

As soon as I create a folder c:\inetpub\wwwroot\isv\script CRM stops responding completely.  Removing the folder fixes the issue.
I pasted, into the onload event, the code from crmservicetoolkit.js file in a <script></script> tag and it writes all the code at the top of the form when tested with create form.  Pasting with no script tag and I have no problem.
I tried the code:

    // Use CrmServiceToolkit.Retrieve() to retrieve a CRM order record.  
    var order1 = crmForm.all.new_ordernoid.DataValue;
    var cols = ["datefufilled"];  
    var retrievedOrder = CrmServiceToolkit.Retrieve("order", order1, cols);  
     
    alert(retrievedOrder.getValue('datefufilled’));
 
in the onchange event of my custom lookup field for order number.  It messes up my lookup for order number to only display one record and no pop up box appears.  Not even a blank one.  No error message.
Ok. What if you give some other name to that folder? I don't think that should be the case but let's just give it a shot. Also the ISV folder was pre-existing right? or you had to make a new one?
"Ok. What if you give some other name to that folder?"

I tried to do that two days ago when I created a folder c:\inetpub\wwwroot\isv\crmservicetoolkit and pasted the contents of the toolkit into it.  CRM stopped responding then as well.  See my post from 3-6.  This time I created the folder script and immediately checked CRM as I expected that it might freeze again.
The ISV folder already existed.  I did not make it.
It is strange I recall using that folder all the times and it never gave me a problem. Let's try something else. Just keep everything under ISV folder. Do not create another folder. After that check if CRM stops working. If it is working then we will move forward. On page load, you will have to dynamically load the crmservicetoolkit.js.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is what accomplished my goal