function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Supriyo Ghosh 5Supriyo Ghosh 5 

Copy Field value from one object to another

Hi,

I am trying to copy one field value to another field through one button click.I have created one custom button and in java script is below.

{!requireScript("/soap/ajax/26.0/connection.js")} 
var emp=sforce.connection.query("Select Branch_Code__r.Name from Employee_Master__c where User__c='{!User.Id}' limit 1"); 
var recs = emp.getArray("records"); 
window.open("https://pfpdl--pdlpcsb.cs31.my.salesforce.com/a0v/e?ent=BDC-Transaction-Detail Edit&save_new_url=%2Fa0v%2Fo&retURL=&00Np0000000mvq0="+recs[0].Branch_Code__r.Name,"_self");

This script is copying the value in the url but not in that field.Anyone please help.
Best Answer chosen by Supriyo Ghosh 5
Virendra ChouhanVirendra Chouhan
Hi Supriyo,

instead of using "recs[0].Branch_Code__r.Name" use emp.records.Branch_Code__r.Name it'll work.

All Answers

Virendra ChouhanVirendra Chouhan
Hi Supriyo,

instead of using "recs[0].Branch_Code__r.Name" use emp.records.Branch_Code__r.Name it'll work.
This was selected as the best answer
Supriyo Ghosh 5Supriyo Ghosh 5
Hi Virendra,

Still it is not working.In the url values are coming

https://pfpdl--pdlpcsb.cs31.my.salesforce.com/a0v/e?ent=BDC-Transaction-Detail%20Edit&save_new_url=%2Fa0v%2Fo&retURL=&00Np0000000mvq0=CITY-1

but I want to put this City-1 value in a custom field.
Virendra ChouhanVirendra Chouhan
Make sure your field name is correct in your case check is this correct "00Np0000000mvq0"
Supriyo Ghosh 5Supriyo Ghosh 5
got it.thanks.