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
qraishqraish 

Record Id in Controller, Query DB,Prepopulate a field,user input another field

Really looking for some help/insights here..Any guidance would be greatly appreciated!!

 

Here's my scenario:

A record id can be obtained in the controller using ApexPages.currentpage().getParameters().get('RecId') when 'RecId' is already parsed in the URL...

 

The problem is: Say a record with id=RecId already exists with values in Field A. Now, we need to prompt user to enter data in Field B and also show them value of Field A by autopopulating..

I am having extremely difficult time to figure out how to tie up both the prepopulate and update process to the same record.

If I use ApexPages.StandardController.getRecord, it would allow me update the Field B. But how can I prepopulate field A. Or vice versa..how to do both at the same time?


Thank you for your time!!

bob_buzzardbob_buzzard

If you use a standard controller and pass the record id as the "id" parameter on the URL, the existing value of field A will be populated when the page is rendered.  The page will be inspected to determine which fields are in use, and these will be automatically queried from the database by the standard controller.  

qraishqraish

Hi Bob, Thanks for your reply...Unfortunately, I'm unable to prepopulate a field in sites page without any logic in the controller...
Here's a generic elaboration of my situation..

 - An existing record with name REC14 in the custom object FIFA__c with value 'Brazil' in the field Venue__c and another field Comments__c  is empty
- Prompting non SFDC users provide Comments_c via Sites Page.
- In that page a disabled inputText inside outputPanel will already be prepopulated with the value of Venue__c of the record REC 14
- Users will provide texts in another inputField which will be stored in Comments__c of the existing record REC 14 on save.

Any more insights on how to tackle this issue?

Thank you!

bob_buzzardbob_buzzard

This sounds more like an issue with the public access settings for the site (aka guest user profile).

 

Standard controllers should work just as well on a site, the only reason you would need to write code to retrieve data is if the sharing model is locked down, but from the sound of it you want an external user to be able to be able to comment on any record.

 

A disabled input field may well give you problems, as you are telling the browser not to send it back to your controller - I'd use an outputfield for that purpose instead.

 

What are the CRUD and FLS settings for the FIFA__c object in the public access settings of the site?

qraishqraish

Actually I am looking for non-SFDC user(external users) to provide Comments_c field input for FIFA__c object all the while pre-populating the Venue__c field..
Been hitting the walls for hours now...I can either populate the Venue__c OR Ask user for Comment__c as input...but nothing makes sense once I try to implement both at the same time...as the Comment__c input needs to get saved to the same record..


bob_buzzard wrote:

This sounds more like an issue with the public access settings for the site (aka guest user profile).

 

Standard controllers should work just as well on a site, the only reason you would need to write code to retrieve data is if the sharing model is locked down, but from the sound of it you want an external user to be able to be able to comment on any record.

 

A disabled input field may well give you problems, as you are telling the browser not to send it back to your controller - I'd use an outputfield for that purpose instead.

 

What are the CRUD and FLS settings for the FIFA__c object in the public access settings of the site?