2

We're using a Visualforce page on the case page layout to automatically assign the case to the user that clicks on it and opens it from the queue. Here is the markup below and it works great, but we need to add a rule to it where it only reassigns the case when the user is assigned to a specific profile ID. Any ideas on how to update this to work? Thanks in advance!

<apex:page standardController="Case">
<apex:remoteObjects >
    <apex:remoteObjectModel name="Case" fields="Id, OwnerId">
    </apex:remoteObjectModel>
</apex:remoteObjects>
<script type="application/javascript">
    var caseToUpdate = new SObjectModel.Case();
    caseToUpdate.set('Id', '{!Case.Id}');
    caseToUpdate.set('OwnerId', '{!$User.Id}');
    caseToUpdate.update();
</script>

0

Not tested code, but I don't see why you couldn't do this:

<apex:page standardController="Case">
<apex:remoteObjects >
   <apex:remoteObjectModel name="Case" fields="Id, OwnerId">
   </apex:remoteObjectModel>
</apex:remoteObjects>
<script type="application/javascript">
   var caseToUpdate = new SObjectModel.Case();
   caseToUpdate.set('Id', '{!Case.Id}');
   caseToUpdate.set('OwnerId', '{!$User.Id}');
   if({!$Profile.Id}=='xxxxxxxxxx'){       
      caseToUpdate.update();
   }
 </script>

Where the xxxxxx is the profile id.

| improve this answer | |
  • You can also use $Profile.Name - makes it a little easier to read later. – CyberJus Mar 31 '15 at 21:55
  • That was the missing piece, I wasn't sure how to write the IF statement and where to place it (just started learning code). Thank you so much for your help! – Kelly Faria Apr 1 '15 at 18:29

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.