0

when click on the new contact button (this is list view javascript custom button) page redirected but account name not populated automatically

    var qc = sforce.connection.query("SELECT Id FROM RecordType WHERE SobjectType ='" + "Contact" + "'" +" AND DeveloperName = '"+"Suppliers"+ "'"); 

    var qc_records = qc.getArray("records"); 

    var qc_rec = qc.records.Id; 

    var qc1 = sforce.connection.query("SELECT Id FROM RecordType WHERE SobjectType ='" + "Contact" + "'" +" AND DeveloperName = '"+"Employee"+ "'"); 

    var qc_records1 = qc1.getArray("records"); 

    var qc_rec1 = qc1.records.Id; 
    if('{! Account.Status__c }' == 'Creditor' ||'{! Account.Status__c }' ==   'Debitor' ||'{! Account.Status__c }' == 'Other External' ) 
    { 
    returnUrl = "/003/e?retURL=%2F{! Account.Id }&cancelURL=%2F{! Account.Id}&RecordType="+qc_rec+"&ent=Contact"; 
   } 
     else 
    { 
returnUrl = "/003/e?retURL=%2F{! Account.Id }&cancelURL=%2F{! Account.Id}&RecordType="+qc_rec1+"&ent=Contact"; 

} 
    window.location.href = returnUrl;

1 Answer 1

1

Update your return url with this.

returnUrl = "/003/e?con4={!Account.Name}&con4_lkid={!Account.Id}&retURL=%2F{! Account.Id }&cancelURL=%2F{! Account.Id}&RecordType="+qc_rec1+"&ent=Contact"; 
5
  • nothing happend Feb 2, 2017 at 10:49
  • @cloudZigZag can you try this returnUrl = "/003/e?con4={!Account.Name}&con4_lkid={!Account.Id}
    – Reshma
    Feb 2, 2017 at 10:51
  • yes i have tried thats why i repied Feb 2, 2017 at 10:53
  • @cloudZigZag did this redirect to contact page?
    – Reshma
    Feb 2, 2017 at 11:02
  • yes its redirected and now its working actually status not set on account that why not working now its worked thanks Feb 2, 2017 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.