Retrieve information from another field / entity

Hello.  I've searched around and found some code for me to be able to get the 
value from two fields in the Account Entity to two fields in the Opportunity 
Entity.  This would happened on the OnChange event of my "client" / "account" 
field.  This field is the customerid field and is type "customer".  It seems 
the code is doing what it's supposed to do until the end...where it's 
supposed to populate the two fields in the opportunity.  I get the following 
error:  
"There was an error with this field's customzied event.  Field: customerid  
Event: onchange  Error: Object doesn't support this property or method".  I'm 
not sure what to do.  The code seems to be getting the value from the 
Account, but maybe it doesn't like the GUID.  I'm not sure.  Any help would 
be appreciated.  Also, the r_cpid and r_mpid are type "lookup".


var AccountLookUp = crmForm.all.customerid.DataValue;

if (AccountLookUp != null && AccountLookUp != 'undefined')

{

var AccountID = AccountLookUp[0].id;

alert(AccountID);
//--------------------------------------------------------------------------------------------------------------------
var Accountxml = '' +

'<?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>' +

' <RetrieveMultiple 
xmlns=\'http://schemas.microsoft.com/crm/2007/WebServices\'>' +

' <query xmlns:q1=\'http://schemas.microsoft.com/crm/2006/Query\' 
xsi:type=\'q1:QueryExpression\'>' +

' <q1:EntityName>account</q1:EntityName>' +

' <q1:ColumnSet xsi:type=\'q1:AllColumns\' />' +

' <q1:Distinct>false</q1:Distinct>' +

' <q1:Criteria>' +

' <q1:FilterOperator>And</q1:FilterOperator>' +

' <q1:Conditions>' +

' <q1:Condition>' +

' <q1:AttributeName>accountid</q1:AttributeName>' +

' <q1:Operator>Like</q1:Operator>' +

' <q1:Values>' +

' <q1:Value xsi:type=\'xsd:string\'>' + AccountID + '</q1:Value>' +

' </q1:Values>' +

' </q1:Condition>' +

' </q1:Conditions>' +

' </q1:Criteria>' +

' </query>' +

' </RetrieveMultiple>' +

' </soap:Body>' +

'</soap:Envelope>' +

'';

alert(Accountxml);

//----------------------------------------------------------------------------------------------------------------------

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

xmlHttpRequest.Open('POST', '/mscrmservices/2007/CrmService.asmx', false);

xmlHttpRequest.setRequestHeader('SOAPAction','http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple');

xmlHttpRequest.setRequestHeader('Content-Type', 'text/xml; charset=utf-8');

xmlHttpRequest.setRequestHeader('Content-Length', Accountxml.length);

xmlHttpRequest.send(Accountxml);

var resultAccountXml = xmlHttpRequest.responseXML;

alert(resultAccountXml);

//----------------------------------------------------------------------------------------------------------------------

var entityNodes = 
resultAccountXml.selectNodes('//RetrieveMultipleResult/BusinessEntities/BusinessEntity');

for (var i = 0; i < entityNodes.length; i++) {

var entityNode = entityNodes[i];

var MPNode = entityNode.selectSingleNode('q1:r_mpid');

var CPNode = entityNode.selectSingleNode('q1:r_cpid');

var MP = (MPNode == null) ? null : MPNode.text;

var CP = (CPNode == null) ? null : CPNode.text;

alert(MP);

alert(CP);
}

//---------------------------------------------------------------------------------------------------------------------

crmForm.all.r_mpid.DataValue = MP;
crmForm.all.r_cpid.DataValue = CP;
}

Thanks!

0
3/16/2009 3:36:41 PM
crm 35858 articles. 1 followers. Follow

1 Replies
466 Views

Similar Articles

[PageSpeed] 30

Assigning a value to a lookup field is a bit more complicated than just 
assign the DataValue. The full concept is described at 
http://mscrm4ever.blogspot.com/2008/09/coding-crm-lookup-fields.html

---
Burkhard Busch
0
3/17/2009 7:53:02 AM
Reply:

Similar Artilces:

New message To, CC, BCC and Subject fields don't accept 'delete'
Hi all, I'm having a bit of a problem, actually more like an annoyance: whenever I create a new mail (that includes replying, forwarding etc...) I can type in the header field no problem. However, if I hit 'delete' or 'back' it does not deletethe characters in the field, but the ones in the email body! the only way I can get rid of something I already typed in those fields is by highlighting it and typing over it. It started happening recently, without me doing anything special. I have tried deleting the normal.dot, frmcache.dat and outcmd.dat (the last too out of hope r...

Update back-end tables, fields, relationships etc...
I am looking for some examples of code or links to code examples to update a back-end database appropriately so it works with the next version of the front-end. Both dbs are Access2007, Example: I have a table tblPreference in the back-end that has a versionNumber field and is set to "1.0". If my latest "2.0" front-end is opened I want it to detect the OLD version 1.0 back-end and run the code to update the back-end to "2.0" and then change the version number. Things I need done include: - adding fields to existing tables - deleting fields from ...

Use Pivot Table to Populate another table dynamically
Hi, I have a pivot table that is pulling from a large table of data with hours and projects for various clients and hours etc. I want to create an invoice that is populated dynamically with the hours and project as they change by client depending on the client filter. Is there anyway to do this? Everything I have tried has not been dynamic. Thanks ...

Field Switched
Hello, I have a syntax error in a Word 2003 calculated form control. I have read many of the articles suggested here when dealing with field switches, etc., but keep getting the syntax error. Here is what I am doing and why. Creating a form that will be used by very inexperienced computer users. Some may fill out the form electonically, thus the form fields, others will print it out and fill it in. It must be as simple as possible. verification field with number fields set to calculate on exit and a total calculated field which shows a zero by default. We cannot have th...

Cursor auto move from one cell to another
How can I have my cursor automatically move from cell C9 to cell A14 after hitting the enter key in cell C9? (note, there may be data entered or else it may be left blank) Thanks all, mikeburg -- mikeburg ------------------------------------------------------------------------ mikeburg's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=24581 View this thread: http://www.excelforum.com/showthread.php?threadid=399546 One way is to use a "named range". Check out this old post: http://tinyurl.com/39vzv -- HTH, RD ===================================...

Formulae for customized field
Dear sir , I want to use the formulae iif (and ( expression1,expression2),truepart,falsepart). But its not working it is sho wing syntex error with And. how to solve the problem? -- Amey B. Vidvans, Planning Engineer Vidvans_amey@rediffmail.com It's almost like EXCEL but not quite. iif (expression1 AND expression2,truepart,falsepart) Watch out for quoted literal text, eg "truepart" for text and flag fields. -- Trevor Rabey 0407213955 61 8 92727485 PERFECT PROJECT PLANNING www.perfectproject.com.au "Amey" <Amey@discussions.microsoft.com...

How to retrieve entirely my contact and Calendar
Very urgent and vital I was able finally to retrieve all my mails and folder in my outlook. I need to do the something for my contacts (my address book) and calendar. Could you please explain to me the step by step, thank you? ...

visio current date and time fields
How can i search a shape's text for occurrences of current date and time fields. Is there a way I can just search the text for a time field and a date field of any format? Thanks in advance. Hello Biggaford, The text of the shape will only return a mix of the inserted field and so you would be able to check for the the 'current date/time' as opposed to just an abitary date using Edit / Find. If you know the format that was used for the inserted fields you might be able to search using a pattern such as: ^?^?/^?^?/^?^?^?^? ....which will return a match for a date. Other...

retrieving old records & saving them as new ones
hi all, I need to create a program in access database, the main form contains 3 subforms. for each month 'Monthly Progress Report for:', the user enters some details in the main form and the subs. these details should be retrieved (when the user tries to add a new record and enters a new 'Monthly Progress Report for:') and stored as new record with the new month stored also in the subforms. i hope i explained it well,.. your help is appreciated, Thanks. Data are stored in tables, not in forms or subforms. If you are talking about storing the month in the subform reco...

Retrieve Product Key Codes
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel We mistakenly left our disk sleeve on a wet counter and ripped the product code stickers. We can only read the last ten digits of each of the 3 product key codes. How can we retrieve replacement key code numbers? <br><br>Thank you, Sue On 2010-02-28 14:16:48 -0800, Sue_Burgess@officeformac.com said: > We mistakenly left our disk sleeve on a wet counter and ripped the > product code stickers. We can only read the last ten digits of each of > the 3 product key codes. How can we retr...

putting a modeless dlg on another dlg (or formview)
Hi, Is it possible to put an entire dialog on top of another dialog or form view? I'm doing it right now by calling the following in the container dialogs OnInitDlg function: int nRet = childDlg.Create(IDD_DIALOG2, this); childDlg.ShowWindow(SW_SHOWNORMAL); In the OnPaint, I move it into the position I want (on top of a disabled, invisible control) with: m_btn2.GetWindowRect(pRect); childDlg.MoveWindow(*pRect); In the childDlg's OnPaint function, I take care to reposition all the buttons, etcs within the childDlg. I've also been successful transferring messages from the incl...

Another RMS accounting weirdness
This isn't the first time something like this has happened. Customer orders a ton of stuff on several different occassions. Five work orders. Customer wants everything delivered at one time. No problem. Today's the day. We're invoicing all five orders with a tender type of 'on account'. 9:47:14AM - TR #1 - $1,171.00 9:48:52AM - TR #2 - $268.00 Previous Balance = $1,171, New Balance = $1439. 9:51:32AM - TR #3 - $1,096 Previous Balance = $1,439, New Balance = $2535. So far, so good. Now for the weirdness: 9:51:54AM - TR #4 - $497 Previous Balance = $1439, New Bala...

Move a field
I created a table in Access 2007 and I want to move a field to a different place on the table. How can I do this without losing my data? Thank you, Dino Diane K wrote: > I created a table in Access 2007 and I want to move a field to a > different place on the table. How can I do this without losing my > data? I can think of no scenario where this should matter, but open the table in design view and then drag the field definition to wherever you want it. -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com Thanks. "Ric...

Xrefs from Form Fields not Visible
I've got a form that uses xrefs (bookmarks) to repeat field text elsewhere in the doc. Some of the xrefs are showing up as gray boxes, but not all are. The xrefs are functional even if invisible. Removing the \h switch from the xref fields and updating the field does not cause the field to become gray. The paragraph style is the same for both visible and invisible xrefs. I'd like them all to be shown as gray boxes so that my (tech-unsavvy) users can see that the fields are actually there. I do have Show Bookmarks (and Field Shading) checked ON in Word Options. Tha...

Moving data from one worksheet to another
I am trying to move data from one worksheet to another - DATA SHEET - COST CODE DESCRIPTION M S O L 010000 Labor Summary 5,000 011700 Burden 1,000 011750 General Liability 500 011775 Data Processing 011900 Equipment Repairs 1,000 4,500 012000 Utilities 200 012100 FLC Equipment 5,000 012200 Non-Owned Equipment Rental 6,000 012220 Toilet Rental 1,190 This is how I want the result to look - SUMMARY SHEET Cost Code CT Description ...

Retrieve File Names in Directories
Can anyone tell me how or if it is possible to start at a particular directory and drill down to all subdirectories and get the names of files and the associated paths of each? I was thinking you can do this with the File System Object within Excel VBA?? If anyone could point me to good web site that covers this, it would be appreciated. I basically want to start at one directory and follow all paths until no more directories. So drill both down and accross. Hopefully I am explaining correctly. Hi SharonM, What do you want to do with them after you get them? Dan At a...

Adding new fields to the schema
I'm trying to find any documentation to tell me how to add fields to the schema, but not seeing anything. Sorry if I overlooked the obvious. You want to look at the deployment manager... it has a help file associated with it. >-----Original Message----- >I'm trying to find any documentation to tell me how to add fields to the >schema, but not seeing anything. Sorry if I overlooked the obvious. > > >. > keep in imnd that while you can add fields you cannot remove them!! take care and research before adding many fields "kb" <anonymous@discuss...

blank field in rule OE6
How can i add a rule that an empty subject will be removed The reason is that you cannot add a blank field Any idea's ThanX Anthony Ask in an Outlook Express forum. This is an Microsoft Office Outlook forum. Outlook Express is family of Internet Explorer and Outlook of the Office family. Here is the link for the right forum http://communities.microsoft.com/newsgroups/default.asp?icp=InternetExplorer Good Luck! -- Robert Sparnaaij [MVP-Outlook] www.howto-outlook.com Tips of the month: -Backup and Restore -Create an Office XP CD slipstreamed with Service Pack 3 ----- "Antho...

Programatically place cursor insertion point at the end of Unbound Textbox field
I've placed Unbound TextBox and subform to show records from a table. By default when form stats all records are shown in subform. As user enters 1 character at a time in Unbound TextBox the OnChange() event is triggerred and I filter the records matching what user is entering. The problem I am facing is after the character is entered and records are filtered when focus is back to Unbound Textbox: The cursor is placed infront of the first character entered. I would like to ensure the cursoer is at the end of the last character enered. I did a lot or searching and reaching and I did mad...

Copying a dynamic range from one sheet below another dynamic range in the same sheet
I need help with Copying a dynamic range from one sheet below anothe dynamic range in the same sheet. The range may vary depending on the query. Could any of you VBA/Exce gurus help me out -- Message posted from http://www.ExcelForum.com ...

how can i use next record from other last record field in access?
i have 2 field, previous value and next value. The 1st record from previous value is keyin manually, while present value are keyin manually everytime. But the next record for previous value is getting from the last record of present value. how can i coding it in access? can any1 help me pls? thx In general, you should not store the same value in 2 records. Instead, get Access to look it up when you need it. For details on how, see: Subquery basics: Get the value in another record at: http://allenbrowne.com/subquery-01.html#AnotherRecord -- Allen Browne - Microsoft MVP. Perth, ...

how create sum function in form field
I'm trying to utilize the sum function in a field on an Outlook 2002 form. I want the form field to sum up the other form fields. Sum is not a function listed in the value tab. Please advise. ...

Reports using memo data field
In past versions of Money, I was able to specify data in the memo field to create reports. I can't figure out how to do that in Money 2002. Is is possible? Never mind -- finally figured it out. (Use Tools, Find to search for keyword in memo field, then click on the Create Report button.) ...

Copy Outlook 2007 contacts to another folder
I'm using Office 2007 and Vista business I'd like to copy about 1/3 of my e-mail contacts from my main contacts folder to a "New Biz" contact folder. Is there a quicker way than dragging them? Can somebody explain the best and fastes way to do this please. -- Ian D Anderson If they all have something in common, you could assign a category to them and filter the view so they all show grouped together. If that sounds like too much work, you can CTRL+ click each contact you want to move. This will let you multi-select more than one contact and then you only have to...

Group on date field in pivot table
I cannot group on a date field in XL2002. I select the field header, and Excel says I cannot group on it. I then select all the data elements, and it makes one big group instead of treating the field as "date." The source data is an Excel spreadsheet, and the data is formatted as date both at the source and it the pivot table. Anyone know why this happens or how I can resolve the problem? If there are blank cells, or cells with text, in the date column, you won't be able to group on that field. William Benson wrote: > I cannot group on a date field in XL2002. I sele...