Hi, i have a problem in CRM. I have a custom field named "new_number" and this field is disabled in form Order. I want to fill this field with autonumbering system which it must working with CRM Web Services, so i make a code that will return the new_number data into the field new_number in CRM Order form. To do that, i think i must working with AJAX (for example if the last record of new_number is A0001, then ajax will return A0002), where i can write my ajax code in Order Form Properties (onSave function at Save button). This is my AJAX code :
function OnSave()
{
var xmlHttp = null;
if (window.XMLHttpRequest) xmlHttp = new XMLHttpRequest();
else if (window.ActiveXObject) xmlHttp = new ActiveXObject("Microsoft.XMLHTTP") ;
if (xmlHttp == null)
{
alert ("Browser does not support HTTP Request") ;
return ;
}
var url = "http://crm:81/OrderNo/getOrderNo.aspx";
xmlHttp.onreadystatechange = function ()
{
if (xmlHttp.readyState==4) crmForm.all.new_limasorderno.DataValue=xmlHttp.responseXML.getElementsByTagName("orderid")[0].firstChild.data;
}
xmlHttp.open("GET",url,true) ;
xmlHttp.send(null) ;
}
But in the fact, the CRM will do save action first, and then fill the new_number field, so the new_number value doesn't filled into the database. Anyone can help me to solve this problem Thx before ^_^.

Ajax in CRM
rusty123
Have you considered putting the code in the OnLoad event instead You can check whether it's a create or update form and only run the code for new orders.
I would probably implement this as a server side callout, however.
Denis Pitcher
Kartini: We passed your issue to the Microsoft support engineers. Here is what they suggest:
Have you tried setting the number at the OnChange event
This way you assign the next number before it is saved to the database.
Here is another suggestion:
USING THE ONSAVE EVENT
This event does not correspond to the standard OnSubmit event exposed by DHTML. It is fired when a user presses the Save or Save and Close button on the form. The event is fired whether the data in the form has been modified or not.
Validating data is a common reason to use the OnSave event. The OnSave event can cancel the save before it is sent back to the server.
If the following code is included, the Save is cancelled.
event.returnValue = false;
TianHon
Read this blog entry I think it has the answer to your question
http://geekswithblogs.net/guentersblog/archive/2006/07/05/84130.aspx
Alex Barrett
I think your problem is that you are making an asynchronous call to your .aspx page. Try making it synchronous:
xmlHttp.open("GET",url,false) ;
FriedConsole