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
uma52551.3972270309784705E12uma52551.3972270309784705E12 

Apex code and Java Script Help

Hi Friends,

Trying to create a visualforce page to enter field values of one object. While we try to hit save it has to check if all fields are entered if not it has to open a window/page to display the missed fields and ask user to enter values there itself and save from that page/window.

I picked one object and 10 fields if 2 fields are not entered in the first page and user tries to hit save it has to open a window/page to show those two fields and user has to enter those fields in the second page/window and hit save. Then the record should be saved.

I wrote normal code which will save record when all fields are provided. Can Any one help me on this code!.

Thanks & Regards, 
Abhishek BansalAbhishek Bansal
Hi Uma,

You can follow the below steps to achieve your requirement :
  1. Define a javascript method as CheckValues(field1,field2) on your page.
  2. Call this method onClick of Save Button and pass the id of your two fields in it.
  3. In your method CheckValues get the value of both fields with help of Ids that you have passed in the method.
  4. If both the fields  are null than open a popup and where you will see both the fields.
  5. After entering the values in popup page store the entered values in two varibales and pass it tou  JS method.
  6. Now from this JS method call a actionFunction and use two param attributes to assign the values to original fields.
  7. Call your save method form action function.
Let me know if you need any help on this.

Thanks,
Abhishek
uma52551.3972270309784705E12uma52551.3972270309784705E12
Hi Abhishek,

thank u so much for ur reply.. I am new to JavaScript with VF pages. Can you help me by giving some sample code for the above scenario..please don't mind.. Thanks!