You need to sign in to do that
Don't have an account?
Roshan singh 21
Based on selected custom pick list field value from visualforce page need to hit related API and then pass value into save method to save record on Custom object
In my current scenario
I am having 4 REST API URL.
url 1. https:// test1/a
url 2 https:// test2/b
url 3 https:// test 3/c
url 4 https:// test 4/d
and picklist value= test1,test2,test3,test4
I want to create a custom picklist field in the visual force page.
based on selected picklist value I want to hit related API and then that URL value I want to pass into save method.
for example, if I will select test1 value then it will refer URL 1 then once I will click on save button then need to hit url 1 and get the record from url 1.
please help me how to achieve this using visualforce page.
Thanks In advance.
I am having 4 REST API URL.
url 1. https:// test1/a
url 2 https:// test2/b
url 3 https:// test 3/c
url 4 https:// test 4/d
and picklist value= test1,test2,test3,test4
I want to create a custom picklist field in the visual force page.
based on selected picklist value I want to hit related API and then that URL value I want to pass into save method.
for example, if I will select test1 value then it will refer URL 1 then once I will click on save button then need to hit url 1 and get the record from url 1.
please help me how to achieve this using visualforce page.
Thanks In advance.
VF
-------------------
<apex:page controller="myController" tabStyle="Account">
<apex:form>
<apex:pageBlock title="Congratulations {!$User.FirstName}">
<apex:inputField value="{!account.name}"/>
<apex:inputField value="{!account.CustomPickListField}"/>
<apex:commandButton action="{!save}" value="save"/>
</apex:pageBlock>
</apex:form>
</apex:page>
APEX
-----------------------
public class MyController {
Map<String,String> urlMAP = new Map<String,String>();
private final Account account;
public MyController() {
account = [SELECT Id, Name, Site FROM Account
WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
// you load map here
urlMAP.put('test1','URL1');
urlMAP.put('test1','URL1');
urlMAP.put('test1','URL1');
urlMAP.put('test1','URL1');
}
public Account getAccount() {
return account;
}
public PageReference save() {
if(account.CustomPickListField!=null && String.isNotEmpty(account.CustomPickListField)){
if(urlMAP!=null && urlMAP.containsKey(account.CustomPickListField)){
String serviceURL = urlMAP.get(account.CustomPickListField);
// call your service / business here
}
}
insert account;
return null;
}
}
Please mark it best if it helps you. Thanks.
Regards,
Pawan Kumar