Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Microsoft CRM 4.0 - Invoice Lookup

Posted on 2011-03-08
5
Medium Priority
?
817 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

AWS Certified Solutions Architect - Associate

This course has been developed to provide you with the requisite knowledge to not only pass the AWS CSA certification exam but also gain the hands-on experience required to become a qualified AWS Solutions architect working in a real-world environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

661 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