• Briana L.
  • NEWBIE
  • 175 Points
  • Member since 2018
  • Technical Consultant


  • Chatter
    Feed
  • 2
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 16
    Replies
I asked this question a little over a week ago: We have person accounts enabled in our org. We have business accounts with a custom picklist field called Business Account Type with the values "Headquarters" and "Branch Office". If "Branch Office" is selected, a validation rule triggers on save that will require a value in a custom text field called Branch ID (Branch_ID__c). On person account is the same Branch ID field and if it is populated with a value that matches the Branch ID on a business account, a custom lookup field to account called Company (Company__c) should auto-poulate with the account name on the person account.

I have tried using the process automation tools; flow and process builder but was unable to get them to work. I think an apex trigger is required to resolve this issue. I have even tried to write the trigger myself but I have very little experience with triggers. Here is what I have so far which I don't think is anything close to what I need:
 
trigger updateCompanyLookup on Account (before insert) {
   
    Set<String> accountIdList = new Set<String>();
    Map<String,String> accNameMap = new Map<String,String>();

    for (Account pa : Trigger.new) {
        accountIdList.add(pa.Branch_ID__c);
    }
    
    for(Account ba : [SELECT Id, Branch_ID__c FROM Account WHERE Branch_ID__c IN  :accountIdList AND IsPersonAccount=True]) {
        if(ba.Branch_ID__c!=null){
                  accNameMap.put(ba.Branch_ID__c,ba.Id);
        }
  
    }
    
    for(Account pa : Trigger.new) {
        if(accNameMap.containsKey(pa.Branch_ID__c)){
            pa.Id = accNameMap.get(pa.Company__c);
        }
    }
}

 
I was trying to place a quick action to display custom lightning component to show a PDF. The quick action popup coming with a default header and footer. The footer has only one cancel action button but we need 3 action button to perform savePDF, emailPDF and cancel.
To achieve this I have created a custom header, body and footer using slds styling. But the content is displayed on the modal popup's body area with some padding and margin. 
Modal popup with custom header and footer loaded from a lightning component
Please help me to modify the padding and margin without affecting other quick action popups on the page.
I am trying to write a SOSL query to find a match on a custom Social Security Number Field. According to the documentation, SOSL should be able to return results for encrypted fields, but the results returned are blank.

My user has "View Encrypted Data" permission.
We are managing a package, but the code includes the namespace.

This SOSL returns 0 rows, and an empty list, even though I KNOW that there are records with '1111' in the social security number custom field because I created them for testing.
List<List<sObject>> results = [FIND '1111' IN 
                               ALL Fields RETURNING 
                               aescsep__SCSEP_Participant__c(id, name, aescsep__social_security_number__c)];
system.debug(results[0]);
I know that the syntax of the SOSL is correct because if a replace the '1111' keyword with something like 'test' I am able to return records that have 'test' in non-encrypted fields.

Can someone please provide a solution that will return matching participants by encrypted SSN?
I have a lightning component which is going to be used for a Quick Action on a record page. I have implemented force:QuickActionWithoutHeader because I need to have custom "save" and "cancel" buttons. However, the modal that pops up for the quick action has a lot of excess white space, which makes the header and footer look out of place. How can I fix this?

Current Output:
User-added image


Desired Output:
(Actually I would even like the modal pop-up to be smaller so that the input fields do not have so much excess white space, but if I can get the header and footer to look right I will settle for that)
User-added image


Component Code:
<aura:component implements="force:lightningQuickActionWithoutHeader,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="FileUploadController">

    <div class="modal-header slds-modal__header slds-size_1-of-1">
        <h4 class="title slds-text-heading--medium" >Upload File</h4>
    </div>
        
        <!-- MODAL BODY / INPUT FORM -->    
    <div class="slds-modal__content slds-p-around--x-small slds-align_absolute-center slds-size_1-of-1 slds-is-relative" aura:id="modalbody" id="modalbody">
        <form class="slds-form--stacked">
            <!-- All the fields for the form input -->
       </form> 
  
    </div>   <!-- End of Modal Content -->  
        
        <!-- MODAL FOOTER -->
		<div class="modal-footer slds-modal__footer slds-size_1-of-1">
            <div class="forceChangeRecordTypeFooter">
                <ui:button class="slds-button slds-button_neutral" label="Cancel" press="{! c.cancel}" /> 
                <ui:button class="slds-button slds-button--brand"
                       label="Save" press="{!c.save}"/>
            </div>
        </div>
</aura:component>

 
I have a lightning component which is going to be used for a Quick Action on a record page. I have implemented force:QuickActionWithoutHeader because I need to have custom "save" and "cancel" buttons. However, the modal that pops up for the quick action has a lot of excess white space, which makes the header and footer look out of place. How can I fix this?

Current Output:
User-added image


Desired Output:
(Actually I would even like the modal pop-up to be smaller so that the input fields do not have so much excess white space, but if I can get the header and footer to look right I will settle for that)
User-added image


Component Code:
<aura:component implements="force:lightningQuickActionWithoutHeader,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="FileUploadController">

    <div class="modal-header slds-modal__header slds-size_1-of-1">
        <h4 class="title slds-text-heading--medium" >Upload File</h4>
    </div>
        
        <!-- MODAL BODY / INPUT FORM -->    
    <div class="slds-modal__content slds-p-around--x-small slds-align_absolute-center slds-size_1-of-1 slds-is-relative" aura:id="modalbody" id="modalbody">
        <form class="slds-form--stacked">
            <!-- All the fields for the form input -->
       </form> 
  
    </div>   <!-- End of Modal Content -->  
        
        <!-- MODAL FOOTER -->
		<div class="modal-footer slds-modal__footer slds-size_1-of-1">
            <div class="forceChangeRecordTypeFooter">
                <ui:button class="slds-button slds-button_neutral" label="Cancel" press="{! c.cancel}" /> 
                <ui:button class="slds-button slds-button--brand"
                       label="Save" press="{!c.save}"/>
            </div>
        </div>
</aura:component>

 
I am trying to write a SOSL query to find a match on a custom Social Security Number Field. According to the documentation, SOSL should be able to return results for encrypted fields, but the results returned are blank.

My user has "View Encrypted Data" permission.
We are managing a package, but the code includes the namespace.

This SOSL returns 0 rows, and an empty list, even though I KNOW that there are records with '1111' in the social security number custom field because I created them for testing.
List<List<sObject>> results = [FIND '1111' IN 
                               ALL Fields RETURNING 
                               aescsep__SCSEP_Participant__c(id, name, aescsep__social_security_number__c)];
system.debug(results[0]);
I know that the syntax of the SOSL is correct because if a replace the '1111' keyword with something like 'test' I am able to return records that have 'test' in non-encrypted fields.

Can someone please provide a solution that will return matching participants by encrypted SSN?
I have a lightning component which is going to be used for a Quick Action on a record page. I have implemented force:QuickActionWithoutHeader because I need to have custom "save" and "cancel" buttons. However, the modal that pops up for the quick action has a lot of excess white space, which makes the header and footer look out of place. How can I fix this?

Current Output:
User-added image


Desired Output:
(Actually I would even like the modal pop-up to be smaller so that the input fields do not have so much excess white space, but if I can get the header and footer to look right I will settle for that)
User-added image


Component Code:
<aura:component implements="force:lightningQuickActionWithoutHeader,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="FileUploadController">

    <div class="modal-header slds-modal__header slds-size_1-of-1">
        <h4 class="title slds-text-heading--medium" >Upload File</h4>
    </div>
        
        <!-- MODAL BODY / INPUT FORM -->    
    <div class="slds-modal__content slds-p-around--x-small slds-align_absolute-center slds-size_1-of-1 slds-is-relative" aura:id="modalbody" id="modalbody">
        <form class="slds-form--stacked">
            <!-- All the fields for the form input -->
       </form> 
  
    </div>   <!-- End of Modal Content -->  
        
        <!-- MODAL FOOTER -->
		<div class="modal-footer slds-modal__footer slds-size_1-of-1">
            <div class="forceChangeRecordTypeFooter">
                <ui:button class="slds-button slds-button_neutral" label="Cancel" press="{! c.cancel}" /> 
                <ui:button class="slds-button slds-button--brand"
                       label="Save" press="{!c.save}"/>
            </div>
        </div>
</aura:component>

 
I asked this question a little over a week ago: We have person accounts enabled in our org. We have business accounts with a custom picklist field called Business Account Type with the values "Headquarters" and "Branch Office". If "Branch Office" is selected, a validation rule triggers on save that will require a value in a custom text field called Branch ID (Branch_ID__c). On person account is the same Branch ID field and if it is populated with a value that matches the Branch ID on a business account, a custom lookup field to account called Company (Company__c) should auto-poulate with the account name on the person account.

I have tried using the process automation tools; flow and process builder but was unable to get them to work. I think an apex trigger is required to resolve this issue. I have even tried to write the trigger myself but I have very little experience with triggers. Here is what I have so far which I don't think is anything close to what I need:
 
trigger updateCompanyLookup on Account (before insert) {
   
    Set<String> accountIdList = new Set<String>();
    Map<String,String> accNameMap = new Map<String,String>();

    for (Account pa : Trigger.new) {
        accountIdList.add(pa.Branch_ID__c);
    }
    
    for(Account ba : [SELECT Id, Branch_ID__c FROM Account WHERE Branch_ID__c IN  :accountIdList AND IsPersonAccount=True]) {
        if(ba.Branch_ID__c!=null){
                  accNameMap.put(ba.Branch_ID__c,ba.Id);
        }
  
    }
    
    for(Account pa : Trigger.new) {
        if(accNameMap.containsKey(pa.Branch_ID__c)){
            pa.Id = accNameMap.get(pa.Company__c);
        }
    }
}

 
Hello,

I'm not getting my code to work out, and believe it is the result of a conflict between the Trigger I've created and a Process builder that was created.  However, for the life of me, I can't figure out where the error in my logic is happening.

Background:
My boss would like to know how many times our Reps have a 30 minute lag between creating/editing tasks.  There are two ways that a task can be created/edited: 1) directly creating/editing a new task from the contact and/or opportunity, and 2) Automatically from a process that is launched when a new contact is created.

As the task can be created as the first actions of the day, as well as not really having a good way of knowing how this task relates to others in the system, I've created some custom fields that will hold a flag on whether it was the first activity of the day (which will always have more than a 30 minutes gap since the last activity action) and whether it was created within 30 minutes of the last task action.  It is these fields that my trigger will update.

Trigger code:
trigger UpdateActivityFlags on Task (before insert, before update) {
    
    Boolean within30Mins = Boolean.valueOf('true');	//assume task was created more than 30 mins since last activity modification
    String userID = UserInfo.getUserId();	//Get User Id for task owner
    DateTime rightNow = system.now();	//get the date/time of when the task is being created
    Date rightNowDate = date.newInstance(rightNow.year(), rightNow.month(), rightNow.day());	//date part only of date/time task is being created
    Task mostRecentTask;
    Date mostRecentTaskDate;
    
    //Need to get most recent activity information
    try{
        mostRecentTask = [SELECT id, LastModifiedDate, LastModifiedTime__c, EditedWithin30MinsOfLastTask__c, Subject
                          FROM Task 
                          Where OwnerId = :userID AND LastModifiedTime__c < :rightNow 
                          ORDER BY LastModifiedTime__c Desc 
                          Limit 1];
        mostRecentTaskDate = Date.newInstance(mostRecentTask.LastModifiedDate.year(), mostRecentTask.LastModifiedDate.month()
                                              , mostRecentTask.LastModifiedDate.day());	//get date portion of most recent activity modification
    } catch(Exception e){
        System.debug('There were no previous tasks for this user. Error information: Type - ' + e.getTypeName() + ' ;  Message - ' + e.getMessage());
    }
    
    //Check if task was created within 30 mins of last activity modification
    //if(mostRecentTask != NULL){	//There IS a previous task to compare myself to
    //    if((rightNow.getTime() - mostRecentTask.LastModifiedTime__c.getTime()) < 1800000 // 30 mins = 1.8E6 milliseconds
    //        || mostRecentTask.Subject.containsAny('- 2 Week Followup') || mostRecentTask.Subject.containsAny('- 2 Month Followup')
    //      ){	
    //        within30Mins = True;
    //    }
    //}
    
    if(mostRecentTask != NULL){	//There IS a previous task to compare myself to
        if(Trigger.isInsert){
            if((rightNow.getTime() - mostRecentTask.LastModifiedTime__c.getTime()) >= 1800000
               && !mostRecentTask.Subject.containsAny('- 2 Week Followup') && !mostRecentTask.Subject.containsAny('- 2 Month Followup')
              ){	
                  within30Mins = false;
              }
        }
        else{
            if((rightNow.getTime() - mostRecentTask.LastModifiedTime__c.getTime()) >= 1800000){
                within30Mins = false;
            }
        }
        
    }
    
    //update flag information
    for (Task t : Trigger.New){
        t.EditedWithin30MinsOfLastTask__c = within30Mins;
        if(mostRecentTask == NULL){	//no previous tasks owned by user
            t.FirstActivityofDay__c = True;	//no other activities means that this is the first one they are creating
        } else {
            if((Date.valueOf(rightNowDate).daysBetween(mostRecentTaskDate)) != 0){	//task creating and last activity modification are not on the same day
                t.FirstActivityOfDay__c = True;
            }
            t.PreviousTaskDateTime__c = mostRecentTask.LastModifiedTime__c;
        }
    }
}
the commented out code is when I set the initial value of the Boolean to false.  However, this really didn't work for the automatic notifications items, so I tried to approach it from the reverse.

Process information for 2 day "automatic" task:
User-added image

Process for 2 week task creation:
User-added image

Process for 2 Month task creation:
User-added image

Questions-Information:
As I stated, as the trigger is on before insert and before update, I think the Process is creating the task, and that is activating the trigger.  However, I thought my trigger had taken into account this information with the check for the subject information.  (I should mention that the words searched for are exactly what is "coded" in the process, and will be the only time this exact phrase is used.)  Even though I've got the information placed into the process, I believe the trigger would over-write it, but thought the subject inclusion would have caught the over-writing and still given it the value it needed, but that's not the case, as my "within 30 minutes" field is not populating with a True value as it should be for these.

Should I be having my trigger execute on After Insert and After Update information, and then update the information on that task again?
 
Hi,
I am uploading the bulk of Quote data using data loader. But while d ooing mapping I am not able to find the Account in mapping. when I have checked the Edit access on Account Name field on Quote its not there. and that Edit aceess is not enabled only. how to add the edit access for that.
Any suggestion would be appriciated. Please suggest this is urgent.

Thanks in Advance.
Regards,
Anuj
Hi, 

I have a String variable in my controller call ChildQuery. I want to pass a value to the string variable from Visualforce page without any javascript or button. How can that be possible? This value needs to be hidden and auto assign as soon as the visualforce page is opened.  

//set the value of Childquery to "write some string value here like ABCD"  without calling <script></script>
// maybe using these tags below? 

<!-- apex:inputHidden  / -->
<!-- apex:param  / -->
<!-- apex:variable / -->

This is what my class would look like. I'm writing a generic class which would be used by many many different visualforce page. So cannot set the value of the variavle in the controller. It has to pass through the visualforce page so I can throw any page and just call this controller class. 
Class sObject {

public string ChildQuery {get; set;}

    public sObjectController(ApexPages.StandardController controller){
      
        system.debug('THIS IS THE VALUE I'M GETTING:' + ChildQuery);

    }

}



 
Hi people, 

I have this apex code that redirects to another Visualforce page when clicked. When I have 3 PageReferences in the apex, they all work.

However when I have 4 PageReference, they all dont work.

Does anyone know why this is by any chance please? 
 
public with sharing class CustomerSatisfactionFR2{
  public String currentRecordId {get;set;}


  public CustomerSatisfactionFR2(ApexPages.StandardController controller){
    this.currentRecordId = ApexPages.CurrentPage().getparameters().get('id');
  }
  
    
  public PageReference UK_Flag () {                   
  		   PageReference pageref = new 
                     PageReference('/apex/CustomerSatisfaction_EN?Id='+currentRecordId); 
                     pageref.setRedirect(true);
                     return pageref;
  }
 
      public PageReference France_Flag () {                   
  		   PageReference pageref = new 
                     PageReference('/apex/CustomerSatisfaction_FR_2?Id='+currentRecordId); 
                     pageref.setRedirect(true);
                     return pageref;
  }


	  public PageReference Dutch_Flag () {                   
  		   PageReference pageref = new 
                     PageReference('/apex/CustomerSatisfaction_NL?Id='+currentRecordId); 
                     pageref.setRedirect(true);
                     return pageref;
  }    

    
    	  public PageReference Germany_Flag () {                   
  		   PageReference pageref = new 
                     PageReference('/apex/CustomerSatisfaction_DE?Id='+currentRecordId); 
                     pageref.setRedirect(true);
                     return pageref;
  }
    
    
    
        	  public PageReference Italy_Flag () {                   
  		   PageReference pageref = new 
                     PageReference('/apex/CustomerSatisfaction_IT?Id='+currentRecordId); 
                     pageref.setRedirect(true);
                     return pageref;
  }
    
   
 
}

Thanks you very much!  
public without sharing class CreateContactController {

    @AuraEnabled
    public static Id createRecord (Contact contact){
        System.debug('Inserting contact with:' + contact.FirstName + contact.LastName + contact.Email);
        Id returnID = null;        
        if(contact != null){
      User u = [SELECT Id, Contact.AccountId FROM User WHERE Id = :UserInfo.getUserId()][0];
            contact.AccountId = u.Contact.AccountId;
            insert contact;
            returnId = contact.Id;
        }
        else {
            System.debug('Could not insert.');
        }
        return returnId;
    }

}
I was trying to place a quick action to display custom lightning component to show a PDF. The quick action popup coming with a default header and footer. The footer has only one cancel action button but we need 3 action button to perform savePDF, emailPDF and cancel.
To achieve this I have created a custom header, body and footer using slds styling. But the content is displayed on the modal popup's body area with some padding and margin. 
Modal popup with custom header and footer loaded from a lightning component
Please help me to modify the padding and margin without affecting other quick action popups on the page.
When I attempt to save my Apex Class I receive the error "Error: Compile Error: Unexpected token 'class timecardEndDateAudit implements Database.Batchable'. at line 3 column 8"
I can't seem to figure out what I'm missing here. 

gobal class timecardEndDateAudit implements Database.Batchable<sObject>,Database.Stateful{

global Database.QueryLocator start(Database.BatchableContext bc){

String query = 'SELECT jstcl__Placement__r.Name , Account_Executive__c , jstcl__Placement__r.Timecard_End_Date_Audit__c FROM jstcl__TG_Timesheet__c WHERE jstcl__Week_Ending__c >= LAST_N_DAYS:14'

return Database.getQueryLocator(query);
global void execute(Database.BatchableContext bc,List<Placement>scope){

for (Placement Placements :scope){
Placements.Timecard_End_Date_Audit__c ='1';
}
update scope;
}
global void finish(Database.BatchableContext bc){}
}
Hi all,

I am facing issues while converting C# code to apex. Below is the C# code:

using System.IO;
using System.Security.Cryptography;
using System.Text;

        {
            //REST API keys for encryption
            const string key = "a678-78js-986s-iujk-8769";
            const string IV = "ohjk-0987-6h7j-12sg-678j";

            //PlainTest of credentials along with DT in UTC for auth
            string plainText = username + Environment.NewLine +
                               password + Environment.NewLine +
                               DateTime.UtcNow.Ticks;

            //Check the input
            if (plainText == null || plainText.Length == 0)
                throw new ArgumentNullException("plaintext", "plaintext cannot be blank.");
            if (key == null || key.Length == 0)
                throw new ArgumentNullException("key", "key cannot be blank.");

            //Get the input as bytes
            byte[] buffPlain = Encoding.UTF8.GetBytes(plainText);

            //Create and setup the crypto objects
            RijndaelManaged crypt = new RijndaelManaged();
            MD5CryptoServiceProvider hashMD5 = new MD5CryptoServiceProvider();
            crypt.Key = hashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(key));
            crypt.IV = hashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(IV));
            crypt.Mode = CipherMode.CBC;

            //Create the memory streams
            MemoryStream ms = new MemoryStream();
            CryptoStream cs = new CryptoStream(ms, crypt.CreateEncryptor(), CryptoStreamMode.Write);

            //Write the data through the crypto stream into the memory stream
            try
            {
                cs.Write(buffPlain, 0, buffPlain.Length);
                cs.FlushFinalBlock();
            }
            finally
            {
                //Close the streams
                cs.Close();
                ms.Close();

                //Clear the crypto objects;
                hashMD5.Clear();
                crypt.Clear();
            }

            //Get the encrypted bytes
            byte[] buffEnc = ms.ToArray();
            StringBuilder ret = new StringBuilder();

            //Convert the bytes to hex with a length of 2
            foreach (byte b in buffEnc)
            {
                ret.AppendFormat("{0:X2}", b);
            }

            return ret.ToString();
        }