• Sabrent
  • SMARTIE
  • 1440 Points
  • Member since 2011

  • Chatter
    Feed
  • 46
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 242
    Questions
  • 672
    Replies
This is the SOQL used in a trigger
 
List<User> usrlst = [SELECT Id FROM User WHERE UserRole.DeveloperName LIKE : '%Customer_Support_Rep%' and IsActive = True];


Instead of UserRole.DeveloperName i would like to use the UserRoleId = '78hjhajhjhjhj'

Hardcoding id is not a good practice.

I would like to store the RoleId in same place like custom setting or custommetadat type setting.

However i don't know how to access the value from the custom setting or custom metadata setting.

Can someone help or point to an example?

Thanks.

 
The requirement is to get the all duplicate contact with firstname,email,Id, duplicate count

I have already tried this method
[SELECT FirstName,LastName,Email, count(Id) tduplicates FROM Contact GROUP BY FirstName,LastName,Email HAVING count(Id)>1]

but it didn't give the Id

please help me out here

Based on the awesome tutorial  here (https://sfdcmonkey.com/2017/01/02/http-callout-lightning-component/)
I created a lightning component to make a Http Callout  
Now I would  like to measure the  usage of this  Http Callout, similar to the 7 day API usage metrics report. However, i want to know which user clicked the button and how many times in a day/week. 

Can some please point me in the right direction or to a documentation/blog to be able to build a lightning component usage metrics. 

I have a couple different upserts built out in Jitterbit that are all supposed to be running everyday. Some of them are working and some of them are not. They are set up to run with the same salesforce user login (whose password is set to Never Expire).

I cannot figure out why some are working and some are not. I scheduled them all at different times throughout the day, so that they don't enter into a race.

If I run the jobs manually they run successfully. 

Can someone offer suggestions or ideas as to what i should be doing to debug?

Thanks. 

I am trying to let the following validation rule work:
 
AND(
AND($User.vub_Bypass_Validation_Rules__c = false, $Profile.Name = 'Profile A'),
OR(AND(OR(ISCHANGED(CaseOwner), ISCHANGED(ContactName), ISCHANGED(Status), ISCHANGED(Internal Comments)),
))
Unfortunately the syntax is not correct.
What I want is to prevent users with the Profile A (for example) to change/edit the standard fields Case Owner, Contact Name (lookup), Status and Internal Comments.

You can not set such fields as read only on page layout level. Users with this profile should be able to edit when Cases are of Record Type "Claim", but not cases of type "Only Information". So I see the only way is with a validation rule.

I would appreciate any help.
 
Currently the 1st Stage in Opportunity is 'Requires Analysis', the business  wants to replace that with Interested'

My question is 
What should i be concerned about before making this change? 
Are there any repurcussions to replacing a stage name from one value other? 
Hi.
I have a few Old Visual Flows in my org and need to disable (and delete, if its possible) them.
Thanks
I need to override standard Create and Edit Actions on Account object with Lightning Component. Is there a way or a type of field that we could cover the following requirement? Have a field with some predifined values but letting user if he wants to enter free text. I would actually like something like Subject field on Task object but i cannot find any way to implement it. Any ideas please ?
Example: I have a picklist field for Citizenship that has some values for Countries (England, Germany, France, ...etc...). But i want to let user enter his own value (for example: German). i have tried using the following but without success:
 
<!--05/09/2019 George Galaios: Code for Iteration Picklist: Citizenship -->
                        <lightning:select aura:id="accCitizenship" label="{!$Label.c.ea_citizenship}" value="{!v.accountRecord.ea_Citizenship__c}" disabled="{!and(v.noExtraPermission, v.noPermAndCleansed)}" class="slds-size--1-of-2 slds-p-horizontal_x-small">
                            <aura:iteration items="{!v.ea_Citizenship_Values}" var="item">
                                <option value="{!item}" selected="{!item==v.accountRecord.ea_Citizenship__c}">{!item}</option>
                            </aura:iteration>
                        </lightning:select>                
                        <!-- End of Code for Iteration -->

 
Why do i see Export option on some reports in lightning and some reports do not have the Export option. ? 

The only reason i can think of is, the reports that have Export option may have been created after feature was delivered in lightning by Salesforce . 

Can someone please verify ? 

Thanks !
 
Hello,

I'm a novice at Apex code and am trying to adjust my extension for SavePDF so that it saves as a file as well.  I get an error message related to the line that says:  file.Origin = 'a';

I am indicating the wrong origin or something?  Or do I need to complete the attachment fully before I can add the file?  Any help would be appreciated!

 
public pageReference savePDF(){
    
        Date dateToday = Date.today();
        String sMonth = String.valueof(dateToday.month());
        String sDay = String.valueof(dateToday.day());
        if(sMonth.length()==1){
          sMonth = '0' + sMonth;
        }
        if(sDay.length()==1){
          sDay = '0' + sDay;
        }
        String sToday = String.valueof(dateToday.year())+ '-' + sMonth +  '-' + sDay ;
        
      PageReference pagePdf = new PageReference('/apex/SalesAgreement_PDF');
          pagePdf.getParameters().put('id', idVal);
          Blob pdfPageBlob;
          pdfPageBlob = pagePdf.getContentAsPDF();
                 
          Attachment a = new Attachment();
          a.Body = pdfPageBlob;
          a.ParentID = idVal;
          a.Name = 'Service_Agreement_' + strOppName + '_' + sToday + '.pdf';
          a.Description = 'Service Agreement_' + sToday;
          insert a;

          ContentVersion file = new ContentVersion();
		  file.Title = 'Service_Agreement_' + strOppName + '_' + sToday + '.pdf';
		  file.PathOnClient = 'Service_Agreement_' + Datetime.now().getTime() + '.txt';
		  file.VersionData = Blob.valueOf('Service_Agreement_' + 
		  Datetime.now().getTime() + '.txt');
		  file.Origin = 'a';
		  insert file;         
    
        
        pop_msg='Successfully saved';
        displayPopup = true;  
       
        
        opp.Signature_Date__c = null;
        opp.Signature_Key__c = '';
        opp.Signature_Name__c = '';
        opp.Signature_URL__c = null;
        opp.Signature__c = null;

        
        update opp;
      return new PageReference('/apex/SalesAgreement_HTML?id=' + idVal);
      
        
    }



 
Hi Team,


I am sorry if my question is stupid, but I tried to use Lightning Starter and create a trial account, I did not receive any notifications on email and cannot change password, SF informs me that the old password incorrect. If I try to change it, SF asks me a secret question, Could you please help me?
// I am trying to translate the following pseudo code to Apex -> base64(hmac-sha256({accessKeySecret}, UTF8({stringToSign})))

// My atempt at translating to Apex
String dateString = Datetime.now().formatGmt('EEE, dd MMM yyyy HH:mm:ss Z'); 

String stringtoSign = 'GET\n\n\n'+dateString;

String secretAccessKey = '9PK^:WAvBrl1?jz3^U{7+)){igpCG\"Y;<.3DGy8gX+' +'\'' + '6p{|D2#MwI#It8{+@W?>*'; 

Blob mac = Crypto.generateMac('HMAC-SHA256', blob.valueOf(stringToSign),blob.valueOf(secretAccessKey)); 

String signature = EncodingUtil.base64Encode(mac); system.debug(signature);

This compiles correctly in Dev Console. However how do i ensure that that I have translated in the format as mentioned in the pseudo code. ? 
Hello Gurus,
I had a trigger(generates an email on department name change) and a test class related to this trigger.  The coverage was 100%. I changed the trigger to fire only when the profile is <> System Administrator.  The trigger is working fine as expected but the Test class is failing.  Here is the trigger code and followed by Test class code.
--------------------------------------------------------------
trigger SendEmailAfterDeptCodeUpdate on Department__c (after update) {
Profile p = [ Select Id, Name from Profile where Id =: UserInfo.getProfileId() ];
        if( !p.Name.equalsIgnoreCase( 'System Administrator' ) ) 
        {
  List<Id> lstdeptsToUpdate=new List<Id>(); 
for(Department__c dept : trigger.new)
{
    If (dept.Name !=trigger.oldMap.get(dept.Id).Name)
    {
    lstdeptsToUpdate.add(dept.Id);
    }
}
    
    If(lstdeptsToUpdate.size()>0)
    {
    Messaging.EmailFileAttachment csvAttc = new Messaging.EmailFileAttachment();
    
   // string header = '*TR Customer Code, *Customer Name,*TR Department ID,*Original Department Code,*New Department Code,*SubBranchCode,TR Customer Id \n';
 string header = 'SubBranchCode,TRCustomerId,TRDepartmentID,OriginalDepartmentCode,NewDepartmentCode,TRCustomerCode \n';

    string finalstr = header ;
    String Emailbody;
        
    
    string csvname= 'template_to_update_WO_inv_dept.txt';
    csvAttc.setFileName(csvname);
    
    system.debug('header:' + header);
     String messageBody,priorvalue;   
    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
    //email.setSubject('Department Code change in Salesforce');     
   for (Department__c dep1 : [Select id, Name,Service_Entity__r.Customer_Name__c,TR_Customer_Code__c,trDepartmentID__c,Service_Entity__r.Sub_Branch__c,Service_Entity__r.Sub_Branch__r.Sub_Branch_Code__c,Service_Entity__r.TR_Customer_Id__c from Department__c where id in : lstdeptsToUpdate and Service_Entity__r.Send_To_TR__c=True])
        {
     priorvalue=trigger.oldMap.get(dep1.Id).Name; 
     //string recordString = dep1.TR_Customer_Code__c + ','+ dep1.Service_Entity__r.Customer_Name__c+','+dep1.trDepartmentID__c +','+priorvalue+','+dep1.Name+','+dep1.Service_Entity__r.Sub_Branch__r.Sub_Branch_Code__c +','+dep1.Service_Entity__r.TR_Customer_Id__c +'\n';
     string recordString = dep1.Service_Entity__r.Sub_Branch__r.Sub_Branch_Code__c+','+dep1.Service_Entity__r.TR_Customer_Id__c+','+dep1.trDepartmentID__c +','+priorvalue+','+dep1.Name +','+ dep1.TR_Customer_Code__c  +'\n';

          finalstr = finalstr +recordString;
      
         messageBody = '<html><body>';
         messageBody = messageBody + 'Here are the details for the change in Department Code in Salesforce ';
         messageBody = messageBody + '<br>';
         messageBody = messageBody + '<br>';            
         messageBody = messageBody + 'TR Customer Code: '+ dep1.TR_Customer_Code__c;
         messageBody = messageBody + '<br>';
         messageBody = messageBody + 'TR Department ID: ' + dep1.trDepartmentID__c;
         messageBody = messageBody + '<br>';
               
         messageBody = messageBody + 'Original Department Code: ' + priorvalue;
         messageBody = messageBody + '<br>';
         messageBody = messageBody + 'New Department Code: ' + dep1.Name;
         messageBody = messageBody + '<br>';
         messageBody = messageBody + '<br>';            
         messageBody = messageBody + 'Additional details are available in the attached excel. Please update the Work Order and Invoicing details with the new department code.';
         messageBody = messageBody + '<br>';
         messageBody = messageBody + '<br>';            
         messageBody = messageBody + 'Assign ticket to - Data Management Backend group';
    
         messageBody = messageBody + '</body></html>';       
    
    blob csvBlob = Blob.valueOf(finalstr);    
    csvAttc.setBody(csvBlob);

    system.debug('----');    
    email.setSubject('Department Code change in Salesforce updated to ' + dep1.Name ); 
    email.setHtmlBody(messageBody);

    email.setToAddresses(new String[]{'raos@gmail.com'});
    email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvAttc});
    system.debug('email...' + email );
    if(email != null)
      {
       Messaging.sendEmail(new Messaging.singleEmailMessage[] {email}); 
       //   system.debug('Inside send email');
      } 
    }        
}
        }
}
--------------------------------------------------------------
@IsTest
public class SendEmailAfterDeptCodeUpdateTest {
static testMethod void SendEmailAfterDeptCodeUpdateTest()
    {
        Profile p = [ Select Id, Name from Profile where name='System Administrator' limit 1 ];
        //Profile p = [ Select Id, Name from Profile where name='Standard Sales User' limit 1 ];
        User standardSales = new User(profileId = p.id, username ='standarduserAdmin@peak.com', email = 'standarduser123@peak.com', 
                                     emailencodingkey = 'UTF-8', localesidkey ='en_US', languagelocalekey = 'en_US', timezonesidkey = 'America/Los_Angeles',
                                    alias='nuser123', lastname='lastname123');
        insert standardSales;
        system.runAs(standardSales)
        {   /*Account a=new Account(Name='Test1',BillingCountry='United States',BillingState='Indiana');
            insert a;
         
            Acquisition__c ac= new Acquisition__c(Name='Test Ac');
            insert ac;
         
            Service_Entity__c Se1=new Service_Entity__c(Customer_Name__c='Testa',Legal_Entity__c='Archive Systems Inc.',Account__c=a.id,AcquisitionDB__c=ac.id);
            insert Se1;*/
            
            Department__c dept1= new Department__c(Name='Test Dept',Department_Name__c='Sample Dept',  CurrencyIsoCode='USD',Service_Entity__c='a0t1W00000Un1kR'); //Se1.Id);
            test.startTest();
            insert dept1;
            test.stopTest();
        }


    }
    static testMethod void updateDepartmentTest1(){
                
        Profile p2 = [ Select Id, Name from Profile where name='Onboarding Team' limit 1 ];
        User standardSales2 = new User(profileId = p2.id, username ='standarduserAdmin123@peak.com', email = 'standarduseranc@peak.com', 
                                     emailencodingkey = 'UTF-8', localesidkey ='en_US', languagelocalekey = 'en_US', timezonesidkey = 'America/Los_Angeles',
                                    alias='nuser123', lastname='lastname1231');
        insert standardSales2;

       system.runAs(standardSales2)
        {   Department__c dept11= new Department__c(Name='Test Dept123',Department_Name__c='Sample Dept123',  CurrencyIsoCode='USD',Service_Entity__c='a0t1W00000Un1qH'); //Se1.Id);
            insert dept11  ;   
            test.startTest();
            dept11.Name='Test Dept1243';
            Update dept11;
            test.stopTest();
        }   
    }
    static testMethod void updateDepartmentTest(){
        Profile p = [ Select Id, Name from Profile where name='System Administrator' limit 1 ];
        User standardSales = new User(profileId = p.id, username ='standarduserAdmin@peak.com', email = 'standarduser123@peak.com', 
                                     emailencodingkey = 'UTF-8', localesidkey ='en_US', languagelocalekey = 'en_US', timezonesidkey = 'America/Los_Angeles',
                                    alias='nuser123', lastname='lastname123');
        insert standardSales;
        system.runAs(standardSales){
            Department__c dept2= new Department__c(Name='Test Dept2',Department_Name__c='Sample Dept2',  CurrencyIsoCode='USD',Service_Entity__c='a0t1W00000Un4UM'); //Se1.Id);
            insert dept2;
            
            test.startTest();
            dept2.Name='Test Dept3';
            Update dept2;
            test.stopTest();
        }
    }
}
--------------------------------------------------------------

I am getting the following error message

System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []

Stack trace is showing this message:
Class.SendEmailAfterDeptCodeUpdateTest.updateDepartmentTest1: line 39, column 1

I have highlighted the line 39.  The new method that i have include is updateDepartmentTest1().

Let me know the mistake I am doing.

Thanks
Rao
I am looking for an integration specialist who can guide me . ? 

I need help with code review for generating HMAC signature . 

 

We have a custom EmailService for inbound messages written in apex, which is processing Inbound email messages and then showing them in a lightning component.
The type od the received email object is EmailMessage. On the production org, when the system administrator is logged in, he sees all the needed incoming emails (the component is showing them as it should be, querying also works). It all worked well in our sandbox though.
The problem is when the user is logged in. The component does not show any emails and they are not visible also by querying. The problem is I suppose with some permissions, but the EmailMessage object in our org is not customizable when it comes to permissions (everything is set to default and is not changeable). The user has a company community licence. Any help or suggestion would be greatly appreciated.
Hello Team,

Below is a requirement from one of our customers.

The objective is to have a parallel approval process on an object.
For Example, when a record is submitted for approval, it has to spawn multiple approval steps(more than 2) in Parallel (say, Approval from Legal team, approval from Finance team). Either of these steps can be approved/rejected in parallel by different sets of approvers.

We can find parallel approvers for a single approval step but not parallel approval steps in the configuration. Can anybody please guide here how to achieve this parallel approval steps?