I have a requirement where if the profile value on the picklist is changed then need to call a delete API.

Approach which I have followed to check the current and the previous values of the picklist using javascript function and call the controller method from action function, which is passing the changed picklist value from vf page to the controller and which I am using to call the API from the controller.

I have written a function which capture the profile values before and after update on the vf page.


    (function () {
             var prevVal;
             var currVal;
            $("[id$='ProfileChangeEvent']").on('focus', function () {
               prevVal = this.value;
             }).change(function() {
            currVal = this.value;
            alert('old val:: '+prevVal);
            alert('new val:: '+currVal);
         if (prevVal != currVal){
              alert('Condition Satisfied');
              alert('current val:: '+currVal);                                                              



This function works successfully and calling the action function.

        <apex:actionFunction name="CallAPIFunction" action="{!CallDeleteAPI}">
        <apex:param value="" assignTo="{!currentValue1}" name="currentValue1" />

This action function is further calling the controller method "CallDeleteAPI" and I am passing the currentValue from page to this method.

public class myClass
    public string currentValue1{get; set;}

    public PageReference CallDeleteAPI()

       System.debug('*******picklist value after Update*****'+currentValue1);
       PageReference pg = Page.demo;
       pg.getParameters().put('id', currentProject.Id);
       return pg;

But the issue is the value of currentValue1 is coming null in the CallDeleteAPI() from the action function due to which my API method doDelete() not invoking.

Also, I can achieve the picklist previous value and the current values using configuration but I would like to go with the coding approach.

Can somebody please help me to understand what's going wrong here?

1 Answer 1


To make actionFunction to be fully workable you need to add rerender attribute in the actionFunction, then only it will work correctly.

 <apex:actionFunction name="CallAPIFunction" action="{!CallDeleteAPI}" rerender="<what you want to rerender like form, or panel>">
        <apex:param value="" assignTo="{!currentValue1}" name="currentValue1" />

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .