Callback functions have been behaving very strangely and I am not sure if I am getting this correct. I have a remoting function which is update records in data base and have just kept a alert on the callback.
But I dont see the alert coming up consistently, 1 out of 5 times it fails to show the javascript alert meaning the callback didnt happen for some reason.
function InsertOrganisation(Name,AddressLine1,AddressLine2,AddressLine3,AddressLine4,City,Country,AliasName,PostalCode,StateOrProvince,BusinessID,RowID,WebsiteURL)
{
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.Organisation_Lookup.InsertOrganisation}',
Name,AddressLine1,AddressLine2,AddressLine3,AddressLine4,City,Country,AliasName,PostalCode,StateOrProvince,BusinessID,RowID,WebsiteURL,
function(result, event){
alert('Inside Callout'+result.Id);
},
{buffer: false,escape: false}
);
}
If you see the alert('Inside Callout'+result.Id) is inconsistent in showing up and shows only most of times. I though callback are synchronous and surely will be triggered, am i missing anything?
Below is the controller of the remoting, I am not performing any compex logic but just upserting the data that i get in the remote call. Why is the callback alert not showing up all the time correctly?
@RemoteAction
global static Organization__c InsertOrganisation(String Name,String AddressLine1,String AddressLine2,
String AddressLine3,String AddressLine4,String City,String Country,
String AliasName,String PostalCode,String StateOrProvince,String BusinessID,String RowID,String WebsiteURL){
Organization__c oOrganisation = new Organization__c();
oOrganisation.Name = Name;
oOrganisation.Address_1__c = AddressLine1;
oOrganisation.Address_2__c = AddressLine2;
oOrganisation.Address_3__c = AddressLine3;
oOrganisation.Address_4__c = AddressLine4;
oOrganisation.City_Name__c = City;
oOrganisation.Country__c = Country;
oOrganisation.Organization_Alias_name__c = AliasName;
oOrganisation.Postal_Code__c = PostalCode;
oOrganisation.State_Province__c = StateOrProvince;
oOrganisation.Organization_Business_ID__c = BusinessID;
oOrganisation.Org_Row_ID__c = RowID;
oOrganisation.Web_Site__c = WebsiteURL;
Upsert oOrganisation Organization_Business_ID__c;
return oOrganisation;
}