Solved

Microsoft CRM 4.0 - Invoice Lookup

Posted on 2011-03-08
5
768 Views
Last Modified: 2012-05-11
I am creating a lookup to the Invoice entity using an N:1 relationship.  This works but I want to populate the lookup with the Invoice ID (the number), not the Name that is returned to my lookup.

Can someone tell me how to get the invoice number to populate the lookup?

Thanks
0
Comment
Question by:apollo7
  • 2
  • 2
5 Comments
 
LVL 27

Expert Comment

by:Chinmay Patel
ID: 35076193
Hi apollo7,

It won't work out of the box. What we will have to do is

 - Keep the invoice lookup as it is and it will always display the name.
 - Add another field to show the invoice number
 - Write a script on change of the invoice lookup to retrieve the invoice number and then populate invoice number field.

If you got the idea and are ok with it let me know, I will write the script.

Regards,
Chinmay
0
 
LVL 1

Author Comment

by:apollo7
ID: 35082026
That sounds good to me, i look forward to seeing the script

Thanks
0
 
LVL 1

Expert Comment

by:smartapp
ID: 35083738
Hi apollo7,

Dynamics CRM always shows the main attribute (name) on the lookup text.
The solution I suggest, is to create a new field and use it for the invoice name. And you add a Script on change of the invoice filed to copy the same value in the main attribute (not the new field).
Can write the script for you if this solution is OK.

Thanks
0
 
LVL 27

Accepted Solution

by:
Chinmay Patel earned 500 total points
ID: 35126638
Hi apollo7,

Here is the script to retrieve the invoice number

var xml = "" + 
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" + 
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + 
 GenerateAuthenticationHeader() +"  <soap:Body>" + 
"    <Retrieve xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" + 
"      <entityName>invoice</entityName>" + 
"      <id>GUID</id>" + 
"      <columnSet xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:ColumnSet\">" + 
"        <q1:Attributes>" + 
"          <q1:Attribute>invoicenumber</q1:Attribute>" + 
"        </q1:Attributes>" + 
"      </columnSet>" + 
"    </Retrieve>" + 
"  </soap:Body>" + 
"</soap:Envelope>" + 
"";

var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");

xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Retrieve");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);

var resultXml = xmlHttpRequest.responseXML;
alert(resultXml.xml);

Open in new window


You will have to replace GUID with the guid from your lookup and once you get the results you will have to process the XML and get the invoice number.

Let me know if you need help with that.

I've started working on a new assignment hence the delay.

Regards,
Chinmay

0
 
LVL 1

Author Closing Comment

by:apollo7
ID: 35150363
Thanks, works well.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now