2

I am trying to create a custom visualforce page that is aware of the Case Status Values that are related to a specific Case Support Process.

I am able to get all Status Picklist Values from a Describe method:

Schema.DescribeFieldResult fieldResult = Case.Status.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

Or I can get there Case Status values from the CaseStatus sObject:

SELECT Id, MasterLabel, ApiName, SortOrder, IsDefault, IsClosed FROM CaseStatus

I can get information about the Support process from the BusinessProcess sObject:

SELECT Id, Name, Description, TableEnumOrId, IsActive FROM BusinessProcess

However I can find no way to link the Case Status Values programatically to a defined Business Process. This can be seen in the UI below. I need to identify Programatically the Selected Case Statuses for a specified Support Process.

enter image description here

  • There doesn’t seem to be a direct way to do so, but you can using metadata api. The api returns picklist values associated to the process. – Jayant Das May 17 '18 at 12:53
  • This is a longstanding problem: getting recordtypes associated with picklist values from schema describes doesn't get you what you want. It's a real shortcoming of the platform. There are convoluted methods using the MDAPI that can help you, but no great solutions. Great summary posted here: salesforce.stackexchange.com/questions/103837/…. – crmprogdev May 17 '18 at 13:36
0

Ideally if its just a pure case status field that you want, an apex:inputField should be sufficient and respect Support Processes given you have setup record types on your controller object.

However I think youre doing something more funky like me. I had the use case of creating a selectList for case values that filtered only 'Closed' statuses that still respects the case support process.

Just a clear gritty way of getting this done using VF and javascript/jquery. Key note would be that inputfield does respect support processes and record types, so my solution is basically rendering a display-none version of said field. Traversing it via jQuery and saving it into a hash array and then using that hash array to toggle the visibility of the core field to be displayed

<apex:inputField id="StatusReference" style="display:none; width: 500px;" value="{!myCase.Status}" />


<apex:selectList id="StatusActual" size="1" style="width: 500px;" value="{!myCase.Status}">

<script>
    j$ = jQuery.noConflict();

    var statusValues = new Array();

    j$('select[id*=StatusReference] option').each(function() {
        console.log(this.text + ' ' + this.value);
        statusValues[this.text] = this.value;
    });

    j$('select[id*=StatusActual] option').each(function() {
         if(statusValues[this.value] == undefined){ this.style.display = 'none';}
    });
</script>

I wish there was a cleaner way but no way I'm messing around with Metadata API for a single drop down :D and salesforce do make it so hard at times and you do just deal with the cards youre dealt. but as a famous quote would say 'These violent delights have violent ends'

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.