+ Start a Discussion
Nurav1982Nurav1982 

Custom Setting vs AJAX/Javascript

Hello All,

I have this following requirement.


I need to expose a button on a non-VF page.
Upon clicking the button, I need to check values from two fields (which are exposed in the page layout) say F1 and F2.
If the fields' value combination do exist from an approved list of combinations then I need to call TIBCO else I need to pop up an error message.

We cannot change the page , in which the button will be placed,  as a VF page.
The fields F1 / F2 are hierarchial picklists.



Eg :

Say the approved List of combinations for F1,F2 are as follows {A,1} {A,2} {A,3}

F1 can have {A,B}

F2 can have {1,2,3,4,5}

Scenario #1 : User has chosen {A,1} and presses this custom button then TIBCO needs to be called

Scenario #2 : User has chosen {B,1} and presses this custom button then error message needs to be shown to the user.
(
***{B,1} is selectable while creating a record because it is supported in the hierarchial picklist combination. But for this ***specific*** functionality, the combination {B,1} is not supported
)


I thought of doing the below for this requirement

Approach #1 : Custom Object/AJAX/Javascript

a) Create a custom object that houses the valid list of combinations.
The custom object will have two custom fields F1,F2 containing only valid combinations.

b) Create a button in the page layout

c) When the user presses the button, use AJAX/Javascript to issue a SOQL SELECT to the custom object from step a).

  c-1 : If I find a record from the custom object then call TIBCO
  c-2 : If I dont find a record from the custom object then popup an error message

Approach #2 : Custom setting

My colleague has suggested me to try out with custom settings instead of the above route but I am not so sure about using that.
Also how different it would be from approach #1 even if I go with custom setting.

Can you guys provide your inputs ?.
Is approach #1 better or approach #2 better ?



Thanks in advance for your time !

Nurav
Best Answer chosen by Nurav1982
harsha__charsha__c
Both the approaches come to same in your scenario, as you are doing the actions in javascript.

Custom settings will be preferred, when the same thing needs to be performed in an apex controller class.

Regards,
- Harsha

All Answers

harsha__charsha__c
Both the approaches come to same in your scenario, as you are doing the actions in javascript.

Custom settings will be preferred, when the same thing needs to be performed in an apex controller class.

Regards,
- Harsha
This was selected as the best answer
Nurav1982Nurav1982
Hi Harsha,

Thanks for your inputs.
I guess I have to take approach #1 because the page is a non-VF page and I cannot be using apex controller for implementing the desired functionality.

But do you believe anything else could be done or the approach #1 is the only way for this scenario.

Your inputs are appreciated :)

Thanks

Nurav

Norm Sherman SFNorm Sherman SF
Since you are executing Javascript on the button click action, why not just call the Ajax toolkit and execute a query.
harsha__charsha__c
I vote for Approach #1, as it does not need any custom development(no extra vf page needed). 

There are other but thay need to have a separate vf page and controller cretaed. So, better go with Approach #1.

Regards,
- Harsha