+ Start a Discussion

Auto filling fields from a Custom Button

Hey all,


Recently I posted a problem about manipulating the URL to auto-fill fields without using Visualforce.  The answer turned out to be that to do this, I would need to hard code in the Id values of the fields and then just throw what I wanted in there. 



/a0F/e?CF00NA0000004riGC_lkid={!Open_Quotes__c.AccountId__c}&CF00NA0000004riGC={!Open_Quotes__c.Account__c}&00NA0000004rmIC={!LEFT(Open_Quotes__c.ERPID__c, (LEN(Open_Quotes__c.ERPID__c) - 3))}&00NA0000004rmFn={!RIGHT(Open_Quotes__c.ERPID__c, 2)}


Ok so we got that working, but now I'm sending this to a Visualforce page that mimics standard functionality, and the <label for> Ids are now: j_id0:theForm:thePageBlock:j_id15:j_id17.  So as you may well surmise, it's no longer working.  So I tried to put it the new values into the formula, and it still doesn't work. 


Any ideas?


Best Answer chosen by Admin (Salesforce Developers) 

Figured it out, and learned something new in the process.


Using system.CurrentPageReference().getParameters().get('Parameter');  works with anything that's passed through the URL bar, not specifically put there by the put() method.  Seems that there is no Salesforce flag to tell whether or not it's an Apex:Param tag.


So instead of the Ids, I just passed through a header string from the calling button and called it from the extension of the Visualforce page using the .get() method. The interesting thing is that at first they wouldn't save, even though they are populated in the fields themselves, but I found a workaround, passing them through another linked Visualforce page, and back. 


So perhaps I've stumbled on a problem (or two)?


1. If the Fields are passed through regardless of using the .get() method, why weren't they updated?


2. If the Fields weren't meant to be manipulated like that, why allow something to pass through?