+ Start a Discussion
David ZhuDavid Zhu 

Cannot pass value to new record of custom object through query string if field is not on page layout.

Hi,
I have a custom object (called AccountRequest__c) used for maintaining requests of accounts. A custom button is created on Account object page.
When user clicks the button, it brings to a page to create a new record on AccountRequest__c. I used the following Query String to pass some values of Account to AccountRequest__c.  

/a00/e?retURL=%2Fa00%2Fo&RecordType=012J00000005KEr&ent=01IJ0000000Afbg&00NJ0000001taui={!Account.SAPAccountNumber__c}&00NJ0000001wk5R={!Account.SAPAccountNumber__c}

Correspondingly, 00NJ0000001taui is for field SAP_number__c on AccountRequest__c and 00NJ0000001wk5R is for field SAP_number_hidden__c.

If I add both SAP_nubmer__c and SAP__number_hidden__c on AccountRequest__c page layout, values are passed as expected. No issue at all.

But If I only add SAP_number__c to page layout. It seems SAP_number_hidden__c has no value passed to. I confirmed this by using validation rule at saving the record.

I ensure the field level security is visible to all profiles and NOT readonly. 

Can some one give me a hand? 

thanks,
David

 
Best Answer chosen by David Zhu
Shashikant SharmaShashikant Sharma

Hi David,

Reason for Issue: When edit view is rendeered in souce ( you could see it by view source ) you will find that fields have html controls created with ids like 00NJ0000001taui is for field SAP_number__c on AccountRequest__c and 00NJ0000001wk5R is for field SAP_number_hidden__c in your case. When you do not have field on page layout the Source code of edit view do not have control with Id as "00NJ0000001wk5R"as it was not rendered. So values do not get copied.

Solution: As you want SAP__number_hidden__c to have smae value as SAP_nubmer__c you could:

  1. Create a Workflow Rule and Field Update -  https://help.salesforce.com/apex/HTViewHelpDoc?id=creating_workflow_rules.htm
  2. Create a Process Using Process Builder
  3. Create a Trigger - It will require APEX Knowledge
As best practice any thing which could be achieved using native configuration should using not be done using Apex code so I would suggest to configura to Workflow Rule.

Thanks
Shashikant

All Answers

Shashikant SharmaShashikant Sharma

Hi David,

Reason for Issue: When edit view is rendeered in souce ( you could see it by view source ) you will find that fields have html controls created with ids like 00NJ0000001taui is for field SAP_number__c on AccountRequest__c and 00NJ0000001wk5R is for field SAP_number_hidden__c in your case. When you do not have field on page layout the Source code of edit view do not have control with Id as "00NJ0000001wk5R"as it was not rendered. So values do not get copied.

Solution: As you want SAP__number_hidden__c to have smae value as SAP_nubmer__c you could:

  1. Create a Workflow Rule and Field Update -  https://help.salesforce.com/apex/HTViewHelpDoc?id=creating_workflow_rules.htm
  2. Create a Process Using Process Builder
  3. Create a Trigger - It will require APEX Knowledge
As best practice any thing which could be achieved using native configuration should using not be done using Apex code so I would suggest to configura to Workflow Rule.

Thanks
Shashikant
This was selected as the best answer
David ZhuDavid Zhu
Thanks Sahshikant. Even through your solution did not exactly resolve my problem, but it gave me ideas of find the way to fix my problem.