• sgribi
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 6
    Replies
I have a Process Builder workflow, that is triggered from a Platform Event (related to Cases). The Proces Builder workflow executes fine except that it does not call a sub-process (Invocable) action. Conceptually, the parent process determines that we should send a Case Close notification, and the sub process should then select the correct email template.

If I put the repetitive conditional logic in the parent process, and assign the send email message action there, all works as expected.

Am I doing something wrong in the assignment of the Case sobject to the sub-process? Is this a process builder bug?
User-added image






 
To notify idea contributiors to a new comment, we leverage an APEX call to deliver email messages to users that have contributed to the idea. The VisualForce email template includes Idea relevant content. All is well so far.

We wanted to add recipient specific content into the email. This worked when notifications are triggered by internal users, but failes when portal/community users trigger the same notifications. 
 
<messaging:emailTemplate subject="Vocera Idea was updated: {!relatedTo.Title}" recipientType="User" relatedToType="Idea">
<messaging:htmlEmailBody >
...
        Recipient...{!Recipient.Id}
...
</messaging:htmlEmailBody>
</messaging:emailTemplate>



After some trial and error, we found that adding {!recipient.id} (or any other recipient attribute) into the template would cause an INVALID_CROSS_REFERENCE_KEY error. 

I have to believe that this relates to User Sharing settings, where we limit portal user's ability to see all other portal users. Has anyone found a method to access the recipient.id (which is a user id) in a VisualForce template (for any user), when sending as a portal user?

With the recipient user id, I can call a component to do the Without Sharing magic and get any other relevant user attribute.
 
  • November 01, 2017
  • Like
  • 0
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);
            }
        }
    }
        
}

 
  • February 24, 2017
  • Like
  • 0
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);
            }
        }
    }
        
}

 
  • February 24, 2017
  • Like
  • 0

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?

  • March 02, 2010
  • Like
  • 0

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);} } }