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
mohd Waseemuddinmohd Waseemuddin 

Unable to change status on Omni-Channel using the setServicePresenceStatus API, when it try invoking it it's giving error on omni-channel as "Couldn’t change your Omni-Channel status." I have only sing browser tab opened and API is enabled.

Unable to change status on Omni-Channel using the setServicePresenceStatus API, when it try invoking it it's giving error on omni-channel as "Couldn’t change your Omni-Channel status." I have only single browser tab opened and API is enabled for my profile.

Can anyone please help.

I used below code for VF page of custom component 
<apex:page >
    <apex:includeScript value="/support/console/44.0/integration.js"/>
    
    <a href="#" onClick="testSetStatus();return false;">Set Presence Status</a>  

    <script type="text/javascript">
    function testSetStatus() {
        sforce.console.presence.setServicePresenceStatus('0N57F000000PDyvSAG');
    }
    </script>
    
</apex:page>

Attached is error message screenshot
Best Answer chosen by mohd Waseemuddin
mohd Waseemuddinmohd Waseemuddin
Thanks Raj Vakati, I tried your code and faced the same issue, However I figured out that in my case, the issue coming when I am using 18 char presence status id in code, when I use 15 char its perfectly working fine.

All Answers

Raj VakatiRaj Vakati
Try this code
 
<apex:page>
    <apex:includeScript value="/support/console/44.0/integration.js"/>
    <a href="#" onClick="testSetStatus('0N5xx00000000081');return false;">Set Presence Status</a> 

    <script type="text/javascript">
        function testSetStatus(statusId) {

            //Sets the user’s presence status to statusID. Assumes that the user was assigned this presence status through Setup.
            //These values are for example purposes only
            sforce.console.presence.setServicePresenceStatus(statusId, function(result) { 
                if (result.success) { 
                    alert('Set status successful');
                    alert('Current statusId is: ' + result.statusId);
                    alert('Channel list attached to this status is: ' + result.channels); //printout in console for lists
                } else {
                    alert('Set status failed');
                }
           }); 
        }
    </script>
</apex:page>

 
mohd Waseemuddinmohd Waseemuddin
Thanks Raj Vakati, I tried your code and faced the same issue, However I figured out that in my case, the issue coming when I am using 18 char presence status id in code, when I use 15 char its perfectly working fine.
This was selected as the best answer