• sowmya Inturi 9
  • NEWBIE
  • 173 Points
  • Member since 2017

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 69
    Replies
Hi,
I am new to salesforce, i am facing an issue to make shipping address unique of every account so that no account has duplicate shipping records.
How to write a trigger for it, and also a warning messsage before saving record if duplicate found.
and if it could be achieve through validation rules or process builder then how i should i do this?
 
Hi All,

How to send email notification to all case team members using triggers. I have requirement  location object is child and case is parent. when status field  is compleate on location object then send email to all case team members, Please any one give me solution
I want to concatenate 5 picklist fields values in a new custom field on the Lead object. All are single pick text fields. The new field can be a formula (read-only) or text field.

Output format: Picklist1_Picklist2_Picklist3_Picklist4_Picklist5
condition :
1. underscore should skip if any value is null or blank.
2. For picklist 1 it should only add selected values (Eg: Pick values: a, b, c, d, e, f: it should only add to the formula when a or b or c is selected else it should be blank)

Can someone help with the formula or workflow for this requirement?
Hi All,
my need is that any time any chatter post is going on case Case Team Members should also receive it.
like whenever Any Chatter post is going on Case than the Case team member is also recieve that post?
my helper class is given below:-
public  without sharing class CaseFeedTriggerHelper {
    public static List<FeedItem> newCasesFeed = new List<FeedItem>();
    public static List<FeedItem> oldCasesFeed = new List<FeedItem>();
    public static Map<Id, FeedItem> newMapCasesFeed = new Map<Id, FeedItem>();
    public static Map<Id, FeedItem> oldMapCasesFeed = new Map<Id, FeedItem>(); 
    
    //Method to add case team members in case record followers.
    public static void AlertToCaseTeamMembers(){
        //set to retrive All cases from case feed
        Set<Id> caseIds = new Set<Id>();
        // link feedItem to Case
        for( FeedItem fi : newCasesFeed ){
            if( fi.ParentId != null && String.valueOf(fi.ParentId).startsWith('500') ){
                caseIds.add(fi.ParentId);
            }
        }
        
        //In case there was a feed insertion on an object other than case
        if (caseIds.size() > 0) { 
            //Map to retrive case team member and caseids
            Map<Id, Id> caseIdToCaseMemberId = new Map<Id, Id>();
            //Because there can be more than one team member
            List<EntitySubscription> listEntitySub = new List<EntitySubscription>();
             // add CaseTeamMembers to Map
            for( CaseTeamMember ctm : [ SELECT id, ParentId, 
                                       MemberId
                                       FROM CaseTeamMember 
                                       WHERE Parentid IN : caseIds
                                      ]){
                   caseIdToCaseMemberId.put(ctm.ParentId , ctm.MemberId);                        
            }
            //check if map has value or not
            if(caseIdToCaseMemberId.size() > 0){
                //create a entitySubscription for case  
                for ( Id caseIdsFromMap : caseIdToCaseMemberId.keySet() ) {
                    EntitySubscription entitySub = new EntitySubscription();
                    entitySub.ParentId = caseIdsFromMap;
                    entitySub.SubscriberId = caseIdToCaseMemberId.get(caseIdsFromMap);
                    listEntitySub.add(entitySub);
                }
            }
            //check if list of EntitySubscription has value
            if (listEntitySub.size() > 0) {
                insert listEntitySub;
            }
        }
    }
}
Any suggestion?
Hi All,

Below is the trigger I got in one of the forums that I modified and works fine. What the trigger does is copies the final approval comment in the approval process and populates in a custom field. Now the requirement is to have comments from all the approval steps to be populated in that custom field including the Approver Name and the Step. 

Thank you

trigger TriggerApprover on zqu__Quote__c (before update) {
    
       if(trigger.isUpdate){
             List<zqu__Quote__c> QuoList =  [Select id,
                                                   (Select  
                                                         ActorId, 
                                                         Comments                                                      
                                                    FROM ProcessSteps
                                                ORDER BY CreatedDate DESC) 
                                                    From zqu__Quote__c
                                                WHERE Id IN : Trigger.new];

             if(QuoList.size() > 0){

               for(zqu__Quote__c Quo : QuoList){
              
                for(zqu__Quote__c Quo1 : Trigger.new) {
                  
                         if(Quo.id == Quo1.id && Quo1.copy_comment__c) {
 
                           if (Quo.ProcessSteps.size() > 0) {
                            
                         Quo1.Approver_Comment__c = Quo.ProcessSteps[0].Comments;
                         Quo1.copy_comment__c = false;
                
                           }

                        }
                 
                    }
               }
             }   
        }  
    }
I have a lightning datatable with checkbox. I want to preselect checkbox on load/refresh of the component. I was able to set selectedRows with id. Console log shows before and after the ids are set. However on UI the checbox does not appear. How can I show the checkbox with the checked mark?

some thing like this - 

var idVal = ['a013D000003R0EQQA0'];
component.set("v.selectedRows", idVal);
console.log( ' Before ', component.get("v.selectedRows") );
        component.set("v.selectedRows", idVal);
        console.log( ' After ', component.get("v.selectedRows") );
Hi there,

I got in between a test class which is should cover both POST and Get Method, for my test the code coverage is just 35%

Can someone help to get 100% code coverage?

Below my apex class,

@RestResource(urlMapping='/CaseAttachment/*')
global with sharing class CaseAttachment{

@HttpGet
    global static List<Attachment> getCaseById() {
       RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String Id = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
          List<Attachment> result =  [Select id, Name, OwnerId, BodyLength, LastModifiedById, LastModifiedDate, ContentType, Body, Description, CreatedDate, CreatedById from Attachment where ParentId = :Id];
        return result;
        }
           
@HttpPost
  global static void doget(String type, String body, String ContentType, String ParentID ){
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String CaseName=req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        String doc=EncodingUtil.Base64Encode(req.requestBody);
         Attachment a = new Attachment();
            a.Name = type;
            a.Body = Blob.valueOf(body);           
            a.ContentType = ContentType;
            a.ParentId = 'Id';
                
        insert a;
        
    }
}

Test Class,
@isTest
private class CaseAttachmentTest {
    @isTest static void testCaseAttachmentOne() {
    
  Test.startTest();
  
  

    //create account
    Account acc = new Account();
    //enter details  
    acc.Name = 'Test Account';
    insert acc;
    
    //create case
    Case c = new Case();
    //enter details
    c.AccountId = acc.Id;
    c.Type = 'My Type';
    c.Origin = 'My Origin';
    c.Status = 'My Status';
    insert c;
  

   RestRequest req = new RestRequest(); 
   RestResponse res = new RestResponse();

    req.requestURI = '/services/apexrest/CaseAccountid/'+c.accountId;  //Request URL
    // req.requestBody = Blob.valueof(Body);
    RestContext.request = req;
    RestContext.response= res;
    CaseAttachment.getCaseById();
    Test.stopTest();



     
        
   
  
  
  
    }
    
}


TIA



 
when ever account type is changed form any value to 'Customer' need to 
send an email to account owner saying your account become customer 
and create a task and assign it to account owner.
Hi,
We use SingleEmailMessage to send a email and want to set the from address as the record owner.
As known, the default email from address is the salesforce user who runs this code snippet. Most existing answers recommend us to use orgwideEmailAddress but we think orgwideEmailAddress is not suitable for our requirement bacause from email address loads dynamically rather than a static address.
We also know setReplyTo and setSenderDisplayName method. Actually, the email from user name is shown as expected, but the from address is not conform. It looks strange, doesn't it?
Does anyone know how to change the default email from address as a dynamic user, such as a record owner or the manager of a record owner?
Thanks.
Hi, I am new to salesforce and i am facing an issue in writing trigger.

The Requirement is like this:
I have 3 objects Account , Contract and Commodity(custom object).

If the account has a Contract or Commodity, the Status(custom field,picklist type) field of the  account must be set to Active.

Please help in resolving the issue.
Any help would be appreciated.
Hi,
    I have one custom object it has two lookup fields account and contacts,whenever i create new record in custom object the account should be selected and the contact of the particular account should be displayed,and the record should be saved.
Hi,

I am setting a crieteria on lead,on which when it meets it changes the owner name and assigning them as the task,


please have a look into it.
I am able to update the owner name but not able to assign the task on it..
global class baychApexTask01 implements Database.Batchable<sObject>{
    
   public String query = 'select id,name,Last_Activity_Date__c from lead where Last_Activity_Date__c > 25';
    
    global database.queryLocator start(Database.BatchableContext BC) {
        return database.getQueryLocator(query);
        
    } //close start method
    
    global void execute(Database.BatchableContext BC, list<lead> scope) {
        List<Task> taskList = new List<Task>();
        user u=[select id, firstName from user where alias='ushar'];
        
        
        for(lead c : scope) {            
            c.OwnerId=u.Id;
            Task tsk = new Task();
            tsk.WhoId = c.Id;
            tsk.OwnerId = u.Id;
            tsk.ActivityDate = System.today();
            tsk.Status = 'Completed';
            tsk.Subject = 'Ownership Transferred';
            tsk.Priority ='Normal';
            taskList.add(tsk);
        }
        try{
            update scope;
        }
        catch(exception e){
            system.debug('=====' +e);
        }
        try{
            update scope;
        }
        catch(exception e){
            system.debug('=========' +e);
        }
        
        
    }    
    
    global void finish(Database.BatchableContext BC) {
        
        AsyncApexJob a = [Select Id, Status, NumberOfErrors, JobItemsProcessed,
                          TotalJobItems, CreatedBy.Email
                          from AsyncApexJob where Id =
                          :BC.getJobId()];
        
        
    } //close finish method
} //close class
Hi,
I am new to salesforce, i am facing an issue to make shipping address unique of every account so that no account has duplicate shipping records.
How to write a trigger for it, and also a warning messsage before saving record if duplicate found.
and if it could be achieve through validation rules or process builder then how i should i do this?
 
Hi Folks,

We have a custom clone button on opportunity in classic to clone opportunity excluding some fields. 
The custom clone is implemented with url - '{!URLFOR($Action.Opportunity.Clone,Opportunity.Id,[retURL=URLFOR($Action.Opportunity.View, Opportunity.Id)],false)}...' through VF page.  We want to use the same functionality in lighting as well, but in lighting the same custom clone button is redirecting to classic clone page.  How do I change the url in VF page to open the lightning standard clone page .

Thanks in Advance.

-Anupama
I have Created a Queue named 'Test Queue 3' where i have added one user(A) and one RoleandSubordinate(B is assigned a role of DirectorDirectSalesD and has one user C as its subordinate), now i need to fetch all the users in this Queue 'Test Queue 3'. 

I went through many posts but did not find any satifactory answers. Any help here is appreciated. Thanks in Advance..!!
Hi guys I would like to add custom button or link to Reports. like below image. User-added image 
Hi All,

How to send email notification to all case team members using triggers. I have requirement  location object is child and case is parent. when status field  is compleate on location object then send email to all case team members, Please any one give me solution
 Compile Error: Invalid type: AccountContactRelation
when adding record in list in last line, it throws error, pls suggest

List<AccountContactRelation> lstACR = new List<AccountContactRelation>();// error here
for(AccountContactRelation ACR : [Select Id, AccountId, ContactId, Roles from AccountContactRelation where ContactId =: sConId and 
                                                      AccountId in : accIds and Roles in : mapConRole.values()]) {
                                                          if(ACR.AccountId == opp.Ship__c)  
                                                              bShip = true;
                                                          if(ACR.AccountId == opp.Bill__c) 
                                                              bBill = true;
                                                        
                        }
 if(!bFoundShip)
                            lstACR.add(new AccountContactRelation(AccountId = opp.Ship__c, ContactId = sConId, Roles = sConRole));
Hi All,
I have two objects Account and Custom Object.Account is the parent and Custom object is child.Account has the picklist field called country and it has some  values like Ind,US,UK,Europe,..etc.And Custom object also has one more picklist called Transport,it has some values like By Road,By Air,By Sea..etc.
while the user selects the value in Account picklist field as "Ind",the value in child object picklist field as "By Road".If the value in Account has Other than "Ind",the value in child object picklist field as "By Air".I did this with ProcessBuilder and created seperate process for two conditions.
I include these two conditions with Process at the time of update record actions using formulas it won't work.which formula used in this??
How to write the trigger for this updating records.can any one provide sample code or any ideas.
thanks in advance.
 
What is the default account to which cases that do not find a match in the contacts email field are assigned to? Or are they not assigned to any account?