• sgribi
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 6
    Replies
We have a requirement to return cases to the default queue when a customer updates a case via comment / email and the current case owner is out-of-the-office. I don't seem to be able to call the assignment rules via APEX.

To reroute the queue, we created the following elements, but were not able to get it to work.
Process Builder triggers when a Case Comment is created, (Criteria being that case owner is out, and the comment is from a customer)
Process builder calls an APEX method that updates the relevant case with the assignmentRuleHeader.useDefaultRule DML option
While the Process Builder event fires (other updates occur such as Case status change), the case owner is not update per the default assignment rules.

We can run the same method via Execute Anonymous, and the case owner changes as expected.

This APEX code is intended to perform magic re-assignment. Logs indicate that the action executes, case id is passed along, and APEX update of the case succeeds; only reassignment does not occur. To rule out access issues, I wrapped the method in a without sharing class. Thus far no luck. Any other suggestions?
/*
* Methods to reroute a case to a queue/default owner via routing rules
*/
public class CaseReroute implements Queueable{
    /*
     * Invoke method from Process builder to reassign cases to queue
     * (see CaseController for reroute without notification)
	*/
    @InvocableMethod(label='Route to Default Queue with Notification' description='Reroutes a case to the queue via standard routing rule')
    public static void rerouteCaseToQueueWithEmail(list<id> caseIds)
    {
        //ID jobID = System.enqueueJob(new CaseReroute(caseIds, true));
        rerouteCaseToQueue(caseIds, true);
    }
    
    public list<id> recordIdList;
    public boolean sendNotification;
    /*
     * Instantiate object 
     * - with id list
     * - plain
	*/
    public CaseReroute(list<Id> caseIdList, boolean pSendNotification)
    {
        recordIdList = caseIdList;
        sendNotification = pSendNotification;
    }
    /*
     * Execute quable batch
	*/
    public void execute(QueueableContext context) {
        system.debug('CaseReroute: Execute for '+recordIdList.size()+' cases.');
        rerouteCaseToQueue(this.recordIdList, this.sendNotification);
    }
    // Add Enqueue method to make update asynchronous; simplify workflows to one vs. many
    public static void rerouteCaseToQueue(list<id> caseIds, boolean sendNotification)
    {
        Database.DMLOptions dmo = new Database.DMLOptions();
        dmo.assignmentRuleHeader.useDefaultRule = true;
        dmo.EmailHeader.triggerUserEmail = sendNotification==true;  // rev 3.1
        dmo.optAllOrNone = false;
        // Create case sobjects
        for(Case[] caseList: [Select Id From Case Where Id in: caseIds]) {
            // Update cases
            if(!caseList.isEmpty()) {
                database.SaveResult[] sr = database.update(caseList, dmo);
                system.debug('rerouteCaseToQueue: Save results:');
                system.debug(sr);
            }
        }
    }
        
}

 

Hi,

 

Today I encountered a problem that I can't explain:

 

I got a record 'recA' shared with a user 'userU' through manual sharing (read-only)

 

When I request the UserRecordAccess object in a 'without sharing' class, all works fine:

[SELECT RecordId, HasEditAccess FROM UserRecordAccess WHERE UserId = :userUid AND RecordId = :recAid LIMIT 1]

=> {RecordId=a0kM0000000jWMxIAM, Id=000000000000000AAA, HasEditAccess=false}

 

 But when I execute the same code in a 'with sharing' class, i get 

 

{RecordId=a0kM0000000jWMxIAM, Id=000000000000000AAA, HasEditAccess=true}  //HasEditAccess should be false}

 

 

It seems like a bug, because when I do this query:

 

[SELECT RecordId FROM UserRecordAccess WHERE UserId = :userUid AND RecordId = :recAid AND HasEditAccess = true LIMIT 1]

 I get not results...

 

 

Please let me know if you have already encountered some problems with the UserRecordAccess object.

 

I'm in API 26

 

Thanks

 

 

I would like to be able to display multiple thumbnails of uploaded images that are stored using CRM Content on a single Visualforce page.  I'm able to get ContentDocuments and ContentVersion using SOQL but am unclear on how to embed this content.  Ideally, I would use the apex:image tag within a repeat using a bound list of ContentVersion elements.  Has anybody done something similar?

Hi,

In my apex script I make a copy of an original list with sObjects, to see at a later phase (eg when saving the objects) wether there has been a change of any of the fields by the user.

I use deepclone (clone(true,true)) to make the copy of the relevant objects which I add to the list. Immediately after the cloning, the objects are identical (assertequals of clone and original returns true), after showing them on a vf page with only outputfields they remain identical,

but after showing them in a vf page with inputfields they are seen different (assertequals of clone and original returns false), although all fields (including system fields like lastmodifieddate and id) are identical (assertequals of the individual fields returns true).

 

Anyone who recognizes this and could think of a way to handle this without having to compare each individual field to check for changes?

 

Hello,
I am trying to retrieve the detail records at the same time as the master record. I added a custom field lookup on Opportunity to Account (Contact__c).
 I get this error in Eclipse for the last line of code: "The configuration of your org has changed, please reload the page. Missing dependent object: Field: Opportunity.ContactId".
Could anybody help?
The business scenario that I have is totry to get is the latest Membership_End_Date__c for all Opportunities related to a given Contact.
 Thanks!

trigger UpdateIndividualMemberEndDate on Opportunity (after insert) { set<ID> contIDs = new Set<ID>(); if(Trigger.isInsert) { for(Opportunity o : System.Trigger.new){ contIDs.add(o.Contact__c); } Contact[] conts = new List<Contact>(); conts = [select Id, (select Membership_End_Date__c from Opportunities Order by Membership_End_Date__c desc) from Contact where ID in :contIDs]; Map<Id, Opportunity[]> contopp = new Map<Id, Opportunity[]>(); for (Contact eachCont: conts) { contopp.put(eachCont.Id, eachCont.Opportunities);} } }