• ashish sharma 188
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 5
    Replies
Hi Folks,
I am working on a scenario in which I have to send emails to someone on the basis of some criteria that are as:
if case owner = 'User'{
  • IF case origin = 'phone' || 'email' {
  •    send email to associated contact from user's CustomerCenter email ID.
  • }
  • else {
  •    send email to supplied email in web to case creation from user's CustomerCenter email ID.
}
if(case owner = 'QUEUE'){
  • IF case origin = 'phone' || 'email' {
  •    send email to associated contact from queue email Id.
  • }
  • else {
  •    send email to supplied email in web to case creation from queue email ID.
}
}


As we know, assignment rules run after triggers, so I am unable to access the owner assigned by assignment rule to that case. I have run the assignment rules manually inside trigger but still not able to see the owner assigned by assignment rules.
I am posting my code as well. 
trigger CaseOriginSendEmail on Case (after insert) {
    
    if(Trigger.isAfter && Trigger.isInsert){
     AssignmentRule  ar = new AssignmentRule();
     ar = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1];
     Case cs = Trigger.new[0];
     Case c = new Case(id = cs.id);
     Database.DMLOptions dmlOpts = new Database.DMLOptions();
     dmlOpts.assignmentRuleHeader.assignmentRuleId= ar.id;
     c.setOptions(dmlOpts);
     Database.upsert(c);
     c=null;
     c=[SELECT id,OwnerID,origin,contactID,contactEmail,suppliedEmail from Case where id =: cs.id];
     String ownerIdStr = c.OwnerId;
        System.debug(cs.OwnerId + '\n'+c.OwnerId);
     if(ownerIdStr.startsWith('005')){
         System.debug('in user');
         User u = [SELECT id, ContactCenter__c from User where id =: cs.OwnerId];
         ContactCenter__c cc = [SELECT ContactCenterEmail__c from ContactCenter__c where name__c =: u.ContactCenter__c];
         System.debug(cc.ContactCenterEmail__c);
         if(cs.Origin != 'web')
             MyEmail1.sendMail1(cs.ContactEmail, cc.ContactCenterEmail__c);
         else{
             if(cs.ContactId!=null)
                 MyEmail1.sendMail2(cs.ContactEmail, cc.ContactCenterEmail__c);
             else
                 MyEmail1.sendMail3(cs.SuppliedEmail, cc.ContactCenterEmail__c);
         }
     }
    else if(ownerIdStr.startsWith('00G')){
        System.debug('in queue');
        Group queue = new Group(id = cs.OwnerId);
        String queueEmail = queue.email;
        if(cs.Origin != 'web')
             MyEmail1.sendMail1(cs.ContactEmail, queueEmail);
         else{
             if(cs.ContactId!=null)
                 MyEmail1.sendMail2(cs.ContactEmail, queueEmail);
             else
                 MyEmail1.sendMail3(cs.SuppliedEmail, queueEmail);
         }
    }
	}
}

In above code ContactCenter__c is a custom setting which is linked to users on the basis of picklist vaues. I can't find any error in above code and no way to get the owner assigned by assignment rule in Trigger. Please help me out.
Hi,

I've developed a custom Open CTI implementation for Lightning Service Console. I've been using Lightning components which are wrapped in a Visualforce page (to be able to create a Call Center and use click2dial - which is not possible without Visualforce as I found out). This results in an iframe which contains the Visualforce page. Unfortunately workspaceAPI stopped working when being in the iframe.
I've used workspaceAPI in the following way:
<lightning:workspaceAPI aura:id="workspace" />
Controller looks like this:
var workspaceAPI = component.find("workspace");
workspaceAPI.openTab({
    recordId:'0012F0000089wQuQAI',
	focus: true
}).then(function(response) {
	console.log('in then');
	workspaceAPI.focusTab({
	    tabId: response
	});
}).catch(function(error) {
	 console.log('in catch');
});
I've double checked that record ID exists. This code does not throw an error, 'in then' and 'in catch' is never logged to JS console and tab is not opened. Basically any functionality of workspaceAPI does not work in iframe.

Thanks for any help.
Marek
 
can someone provide me batch apex code for the folowing requirement ?

1 - if account name and billing address are same then it will not insert record and through error . 
2 - if account name and phone are same then it will not insert and through error .


is there any other way how to achieve this . i tried for trigger but number of records are more so it is throwing governemnt limit error .

Thanks,
 
Hi Folks,
I am working on a scenario in which I have to send emails to someone on the basis of some criteria that are as:
if case owner = 'User'{
  • IF case origin = 'phone' || 'email' {
  •    send email to associated contact from user's CustomerCenter email ID.
  • }
  • else {
  •    send email to supplied email in web to case creation from user's CustomerCenter email ID.
}
if(case owner = 'QUEUE'){
  • IF case origin = 'phone' || 'email' {
  •    send email to associated contact from queue email Id.
  • }
  • else {
  •    send email to supplied email in web to case creation from queue email ID.
}
}


As we know, assignment rules run after triggers, so I am unable to access the owner assigned by assignment rule to that case. I have run the assignment rules manually inside trigger but still not able to see the owner assigned by assignment rules.
I am posting my code as well. 
trigger CaseOriginSendEmail on Case (after insert) {
    
    if(Trigger.isAfter && Trigger.isInsert){
     AssignmentRule  ar = new AssignmentRule();
     ar = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1];
     Case cs = Trigger.new[0];
     Case c = new Case(id = cs.id);
     Database.DMLOptions dmlOpts = new Database.DMLOptions();
     dmlOpts.assignmentRuleHeader.assignmentRuleId= ar.id;
     c.setOptions(dmlOpts);
     Database.upsert(c);
     c=null;
     c=[SELECT id,OwnerID,origin,contactID,contactEmail,suppliedEmail from Case where id =: cs.id];
     String ownerIdStr = c.OwnerId;
        System.debug(cs.OwnerId + '\n'+c.OwnerId);
     if(ownerIdStr.startsWith('005')){
         System.debug('in user');
         User u = [SELECT id, ContactCenter__c from User where id =: cs.OwnerId];
         ContactCenter__c cc = [SELECT ContactCenterEmail__c from ContactCenter__c where name__c =: u.ContactCenter__c];
         System.debug(cc.ContactCenterEmail__c);
         if(cs.Origin != 'web')
             MyEmail1.sendMail1(cs.ContactEmail, cc.ContactCenterEmail__c);
         else{
             if(cs.ContactId!=null)
                 MyEmail1.sendMail2(cs.ContactEmail, cc.ContactCenterEmail__c);
             else
                 MyEmail1.sendMail3(cs.SuppliedEmail, cc.ContactCenterEmail__c);
         }
     }
    else if(ownerIdStr.startsWith('00G')){
        System.debug('in queue');
        Group queue = new Group(id = cs.OwnerId);
        String queueEmail = queue.email;
        if(cs.Origin != 'web')
             MyEmail1.sendMail1(cs.ContactEmail, queueEmail);
         else{
             if(cs.ContactId!=null)
                 MyEmail1.sendMail2(cs.ContactEmail, queueEmail);
             else
                 MyEmail1.sendMail3(cs.SuppliedEmail, queueEmail);
         }
    }
	}
}

In above code ContactCenter__c is a custom setting which is linked to users on the basis of picklist vaues. I can't find any error in above code and no way to get the owner assigned by assignment rule in Trigger. Please help me out.
I have a command button on records within a PageBlockTable and want to pass a parameter to the controller. I am aware of the workaround with the Rerender attribute but I cannot use this because I am using an InputFile within my pageblock.

I have also tried a fix using ApexPages.currentPage().getParameters().get(someName) but that does not work either. Here is my current VF excerpt:
 
<apex:column headerValue="Re-Order">
     <apex:commandButton action="{!agendaSortTop}" value="T" title="Move this agenda item to the top of the list" disabled="{!(ag.Sequence__c == agendaFirstSeq)}" >
          <apex:param name="agendaSortTop" value="{!ag.id}"/>
     </apex:commandButton>
</apex:column>

and here is the controller trying to pick up the named parameter.
 
public pagereference agendaSortTop()
    {

       id agendaId = ApexPages.currentPage().getParameters().get('agendaSortTop');

        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 
            'Agenda item "' + agendaId + '" to Top',''));  

        Return null;
    }
This returns a null value in the field

Any ideas?


PS: I cannot use a CommandLink because I need to be able to disable the button.