• Mentee
  • NEWBIE
  • 5 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 18
    Replies
<apex:page docType="html-5.0" standardController="Task">
    <div>
        <audio controls="true" preload="auto">
            <source src="https://mydomain.salesforce.com/servlet/servlet.FileDownload?file=0698c00000Allk9AAB"/>
        </audio>
    </div>
  <!--  <apex:outputLink value="https://mydomain.salesforce.com/servlet/servlet.FileDownload?file=0698c00000Allk9AAB" id="theLink" type="audio/mp3" rendered="" >Play Recording (mp3)</apex:outputLink>-->
</apex:page>

Need inputs please?
  • August 16, 2022
  • Like
  • 0
Name- aws_WScallout
url - https://servicename.amazonaws.com
Identity Type - Named Principal
Authentication Protocol - AWS Signature Version 4
AWS Access Key ID - ******
AWS Secret Access Key - ********
AWS Region - us-east-1
AWS Server- executea
Generate Authorization Header - true 
 
String token ='abcdefghijkl'; (say)
 HttpRequest req = new HttpRequest();
 req.setEndpoint('callout:aws_WScallout/alpha/plan/5?Source=Ops&localen=NA');
 req.setMethod('GET');
 Http http = new Http();
 HTTPResponse res = http.send(req);
 while (res.getStatusCode() == 302) {
           res.setEndpoint(res.getHeader('Location'));
           res = new Http().send(req);
       }
 System.debug(res.getBody());

I have to add x-amz-access-token which I get programmatically from another webservice. without adding error I am getting.
DEBUG|{"message": "Missing required request parameters: [x-amz-access-token]"}
how should I add to this callout?
I tired doing this 
  • req.setHeader('x-amz-access-token', token); 
  • req.setHeader('Authorization', EncodingUtil.base64Encode( Blob.valueof('x-amz-access-token'+ token)));
  • req.setHeader('x-amz-access-token', EncodingUtil.base64Encode(Blob.valueof(token)));

I get this error
DEBUG|{"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method..."}
  • December 06, 2019
  • Like
  • 0
I displaying data in a table using <apex: repeat> and  Lightning Design System in a visualforce page. And using data tables.js I am paging the data. pagination numbers, instead of appearing on bottom right , horizontally. is displays vertically. Any inputs?
pagination issue with Datatables.js
  • November 21, 2018
  • Like
  • 0
I have a page that iterates a list object to display the records. Once clicked on save, I updated the same list with new values and debug logs shows the update list but output panel is not rerender'ed and I dont see updated list on VF page.
 
<apex:outputLabel >A  </apex:outputLabel>
        <apex:inputfield id="idAText" value="{!ttlookup.A}" />
      <apex:inputCheckbox id="checkBoxTMId" value="{!Acheckbox}"/>
      <apex:outputLabel > Check if you want to clear all values 
</apex:outputLabel>

    <apex:commandButton id="btnSave" value=" Save " action="{!Save}" reRender="idPanel" />

 <apex:outputPanel ID = "idPanel">
        <div class="container">   
            <table>
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th> 
                        </tr>
                    </thead>
                    <tbody>
                        <apex:repeat value="{!ryList}" var="tt">
                                <tr>
                                    <td>{!tt.name}</td>
                                    <td>{!tt.Type__c}</td>
                                </tr>
                        </apex:repeat>
                    </tbody>
            </table>

Controller Method :
 
public void save(){
    Boolean noUpdateFlag = false;
    for(MyObjec ttry: ryList){
        if(ttlookup.A !=null){
            noUpdateFlag = true;
            ttry.name = ttlookup.A;
        }

        if(Acheckbox){
            noUpdateFlag = true;
            ttry.name = null;
        }

    }
    system.debug(ryList[0].B + ' noUpdateFlag '+noUpdateFlag);
    try{
        if(noUpdateFlag){
            update ryList;
            ApexPages.addmessage(new Apexpages.message(apexpages.severity.CONFIRM, 'records are saved.'));
        }
        else
            ApexPages.addmessage(new Apexpages.message(apexpages.severity.Info, 'no value entered '));
    }catch(Exception ex){
        System.debug(ex);
        ApexPages.addmessage(new Apexpages.message(apexpages.severity.Error, 'Something went wrong'));
    }

}

and moreover when I add reRender = "idPanel" my apex messages are not displayed. I have no clue why :( any inputs please?
  • October 22, 2018
  • Like
  • 0
String query = 'FIND \'*' + searchString + '*\' IN ALL FIELDS RETURNING Ticket__C (Region__r.name, Manager__c, Manager__r.name, Name, Notes__c), user(id,Name)'; 
 I am searching with user name and results are zero.
 Aim: when a string is entered, it should match with any of the fields of ticket and display the results. with the above query, it will match only with Ticket.name and shows zero results when i am searching for the user.name.  any inputs please
  • October 16, 2018
  • Like
  • 0
I am trying to show a popup when picklist is selected but I am unable to do
I tired this https://developer.salesforce.com/forums/?id=906F0000000DDKiIAO
dint work :(

        <apex:outputPanel">
          <apex:outputLabel>Pick one</apex:outputLabel><br/>
          <apex:selectList id="picklst" value="{!selectedValue}" size="1" required="TRUE" multiselect="FALSE">
              <apex:selectOptions value="{!Lst}"/>
              <apex:actionSupport event="onchange" action="{!func}"/>
          </apex:selectList>
        </apex:outputPanel>

I mean it works but doesn't execute <apex:actionSupport event="onchange" action="{!func}"/> as this render the VF components to display form page. I want to display a popup when someone change to value1 to value2. saying data will be lost. Any ideas
<apex:page docType="html-5.0" standardController="Task">
    <div>
        <audio controls="true" preload="auto">
            <source src="https://mydomain.salesforce.com/servlet/servlet.FileDownload?file=0698c00000Allk9AAB"/>
        </audio>
    </div>
  <!--  <apex:outputLink value="https://mydomain.salesforce.com/servlet/servlet.FileDownload?file=0698c00000Allk9AAB" id="theLink" type="audio/mp3" rendered="" >Play Recording (mp3)</apex:outputLink>-->
</apex:page>

Need inputs please?
  • August 16, 2022
  • Like
  • 0
==============Apex Class=================
public without sharing class contactClass {    
        @AuraEnabled
        public static string saveContact(Lead LeadRec, string file, string fileName) {
          string LeadID;
          try{
            Lead l = new Lead();
            list<Lead> leadList = [select Id, Email from Lead where Email =:LeadRec.Email];
            system.debug('EmailListLength  ' + leadList.size()); 

            Contact c = new Contact();
            list<Contact> conList = [select Id, Email from Contact where Email =:LeadRec.Email];
            system.debug('EmailListLength  ' + conList.size()); 
                      
            if(leadList.size() > 0 || conList.size() > 0 ) {
            system.debug('Duplicate email Not Allowed');    
            //return 'Duplicate email not allowed';        
            throw new AuraHandledException('First name is required');      
            }                               
            else {      
            Insert LeadRec;      
            }    
            LeadID = LeadRec.Id;
            String base64File = EncodingUtil.urlDecode(file, 'UTF-8');
            ContentVersion contentVersionRec = new ContentVersion();
            contentVersionRec.Title = fileName;
            contentVersionRec.PathOnClient = '/' + fileName;
            contentVersionRec.FirstPublishLocationId = LeadRec.Id;
            contentVersionRec.VersionData =      EncodingUtil.base64Decode(base64File);
            contentVersionRec.IsMajorVersion = true;
            Insert contentVersionRec;
            
          }
          catch(Exception ex){
            system.debug('Exception===>'+ex.getMessage());
          }
          return LeadID;
        }        
      }


===================TEST CLASS=======================
@isTest
public class contactClassTest {
    @isTest
     static void positiveCheckMethod(){
        Lead objLead = New Lead();
        objLead.LastName = 'Test';
        objLead.FirstName='Upload';
        objLead.Company = 'Test Company';
        objLead.status='New';
        objLead.School__c='VVPS';
        objLead.Sport__c='Cricket';
        objLead.Email='abc@gmail.com';
        objLead.Phone='9988776655';
        insert objLead;
        
        contact objCon = new contact();
        objCon.FirstName='Test 1';
        objCon.Email='abcdef@gmail.com';
        objCon.LastName='Upload';
        objCon.Phone='1234567876';
        insert objCon;
            
        ContentVersion cv = new ContentVersion();
        cv.Description  = 'test description';
        cv.PathOnClient ='test_file.txt';
        cv.Title = 'test file '+DateTime.now();
        cv.versiondata=Blob.valueOf('test file body');
        cv.FirstPublishLocationId = objLead.Id;
        insert cv;
        system.debug(cv);
        
         Blob csvFileBody =cv.VersionData;
         String csvAsString= csvFileBody.toString();
         system.debug(csvAsString);
        
        
        
        contactClass.saveContact(objLead,csvAsString,'test file');
        

           
    }
      @isTest
      public static void negativCheckMethod(){
        lead l1 = new lead();
        contactClass.saveContact(l1,'demo','test file');
    }   
}
I have the following code:
String query = ' ';

query = 'SELECT Id, Name FROM Location ';
        
List <Location> Locations = database.Query(query);

I am getting an error: Illegal assignment from List<SObject> to List<System.Location>
Dear Experts,

I am getting "System Limit Exception: Apex CPU time limit exceeded" on my trigger. Kindly help me to correct the logic. Thank you very much for your quick help!

Trigger
trigger ContactTrigger on Contact (before insert, after insert, before update, after update) { 
    
    if(Trigger.isBefore && ContactTriggerHandler.runContactTrigger){
        if(Trigger.isInsert || Trigger.isUpdate){
            ContactTriggerHandler.validateAliedRegistrationNumbers(Trigger.new);
            ContactTriggerHandler.validateAClientMDHHSNumbers(Trigger.new);
            ContactTriggerHandler.setContactAccountByCaseIds(Trigger.new);
        }
    }
    if(Trigger.isAfter && ContactTriggerHandler.runContactTrigger){
        
        if(Trigger.isInsert){
            ContactTriggerHandler.getHouseholdAcctsForSharing(Trigger.new, Trigger.newMap);
            ContactTriggerHandler.runContactTrigger = false;
            ContactTriggerHandler.insertSubsidiaryAccounts(Trigger.new);
        }
        if(Trigger.isUpdate){
            ContactTriggerHandler.runContactTrigger = false;
        }
    }

Trigger Handler
 
public class ContactTriggerHandler {

    public static Boolean runContactTrigger = true;
    
    public static Id accountHouseholdRT = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Household').getRecordTypeId();
    public static Id accountOrganizationRT = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Organization').getRecordTypeId();
    public static Id accountVolunteerRT = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Volunteer_Household').getRecordTypeId();
    public static Id contactProviderRT = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Provider').getRecordTypeId();
    public static Id contactClientRT = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Client').getRecordTypeId();
    public static Id contactURMRT = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('URM').getRecordTypeId();
    
    //Method: getHouseholdAcctsForSharing
    //Desc:   When a new Provider rType Contact is created, they need to be granted access to all Household Accounts that all Agency employees from their Agency 
    //        have access to. If new provider is part of an agency, that is a parent agency to other agencies (top level account), then they should also have access
    //        to all child agency related Household Accounts 
    public static void getHouseholdAcctsForSharing(List<Contact> newContacts, Map<Id, Contact> newMap){
        
        List<AccountContactRelation> relatedHouseholdAccts = new List<AccountContactRelation>();
        Map<Id,List<Id>> householdIdAgencyAll = new Map<Id,List<Id>>();
        Set<Id> providerAgencyIds = new Set<Id>();
        Set<Id> agencyContacts = new Set<Id>();
        Map<Id, List<Id>> agencyWithEmployees = new Map<Id, List<Id>>();
        Map<Id, List<Id>> agencyEmpWithHouseholdIds = new Map<Id, List<Id>>();
                
        for(Contact c : newContacts){
            
            if(c.RecordTypeId == contactProviderRT){
                providerAgencyIds.add(c.AccountId);
            }
        }
        
        system.debug(providerAgencyIds.size());
        
        if(providerAgencyIds.size()>0){
            //Get URM & Provider contacts related to agency of new employee
            List<AccountContactRelation> relatedAgencyEmployees = [SELECT Id, AccountId, ContactId, Roles 
                                                                   FROM AccountContactRelation WHERE AccountId IN:providerAgencyIds
                                                                   AND Contact.RecordTypeId =:contactProviderRT];
            
            system.debug(relatedAgencyEmployees.size());
            
            List<Id> agencyEmpIds = null;
            
            for(AccountContactRelation acr : relatedAgencyEmployees){
                
                agencyContacts.add(acr.ContactId);
                agencyEmpIds = agencyWithEmployees.get(acr.AccountId);
                
                if(agencyEmpIds == null){
                    agencyEmpIds = new List<Id>();
                }
                agencyEmpIds.add(acr.ContactId);
                agencyWithEmployees.put(acr.AccountId, agencyEmpIds);
            }
            
            if(agencyWithEmployees.size()>0){
                
                //Get all household accts that agency contacts have access to for assignment to new employee 
                relatedHouseholdAccts = [SELECT Id, AccountId, ContactId, Roles FROM AccountContactRelation 
                                         WHERE ContactId IN:agencyContacts AND (Account.RecordTypeId =:accountHouseholdRT OR Account.RecordTypeId =:accountVolunteerRT)];

                List<Id> householdIds = null;
                
                for(AccountContactRelation acr : relatedHouseholdAccts){
                    
                    householdIds = agencyEmpWithHouseholdIds.get(acr.ContactId);
                    
                    if(householdIds == null){
                        householdIds = new List<Id>();
                    }
                    householdIds.add(acr.AccountId);
                    agencyEmpWithHouseholdIds.put(acr.ContactId, householdIds);
                }

                List<Id> hIds = null;
                //agency Id
                for(Id aId : agencyWithEmployees.keyset()){
                    //employee contact Ids
                    for(Id eId : agencyWithEmployees.get(aId)){
                        
                        if(agencyEmpWithHouseholdIds.keyset().contains(eId)){
                            
                            List<Id> relatedHIDs = agencyEmpWithHouseholdIds.get(eId);
                            system.debug(relatedHIDS.size());
                            hIds = householdIdAgencyAll.get(aId);
                            
                            if(hIds == null){
                                hIds = new List<Id>();
                            }
                            for(Id rHids : relatedHIDS){
                                hIds.add(rHids);
                            }
                            
                            system.debug(hIds.size());
                            householdIdAgencyAll.put(aId, hIds);
                        }
                        
                    }
                }

                List<AccountContactRelation> householdRelationshipsToCreate = new List<AccountContactRelation>();
                Map<Id, AccountContactRelation> householdRelationshipMap = new Map<Id, AccountContactRelation>();
                Map<Id, Set<Id>> agencyContactWithHouseholdIds = new Map<Id, Set<Id>>();
                List<Id> hhIds = null;
                Set<Id> hhSet = new Set<Id>();
                
                for(Contact c : newContacts){
                    hhIds = householdIdAgencyAll.get(c.AccountId);
                    
                    if(hhIds != null){
                        hhSet.addAll(hhIds);
                        agencyContactWithHouseholdIds.put(c.id, hhSet);     
                    }
                }
                
                if(agencyContactWithHouseholdIds.size()>0){
                    
                    for(Id cId : agencyContactWithHouseholdIds.keyset()){
                        
                        for(Id hhId : agencyContactWithHouseholdIds.get(cId)){
                            
                            AccountContactRelation acr = new AccountContactRelation();
                            acr.ContactId = cId;
                            acr.AccountId = hhId;
                            acr.IsActive = true;
                            acr.Roles = 'Agency';
                            householdRelationshipsToCreate.add(acr);
                        }
                    }
                }

                if(householdRelationshipsToCreate.size()>0){
                    insert householdRelationshipsToCreate;
                }
            }
        }
    }

    public static void validateAliedRegistrationNumbers(List<Contact> newRecords){
        
        for(Contact c : newRecords){
            
            if(c.Alien_Number__c != null && c.Alien_Registration_Number_DW__c == null){
                c.Alien_Registration_Number_DW__c = c.Alien_Number__c;
            } 
            
            else if(c.Alien_Registration_Number_DW__c != null && c.Alien_Number__c == null ){
                c.Alien_Number__c = c.Alien_Registration_Number_DW__c;
            }

            if(c.Alien_Number__c != null){
                string aliennumber = c.Alien_Number__c;
                c.Alien_Number__c = aliennumber.replaceAll('[^0-9]', '');
            }

            if(c.Alien_Registration_Number_DW__c != null ){
                string aliennumber = c.Alien_Registration_Number_DW__c;
                c.Alien_Registration_Number_DW__c = aliennumber.replaceAll('[^0-9]', '');
            }

        }
    }
    public static void validateAClientMDHHSNumbers(List<Contact> newRecords){
        
        for(Contact c : newRecords){

            if(c.MD_ID__c != null && c.Client_MD_ID__c == null){
                c.Client_MD_ID__c = c.MD_ID__c;
            } else if(c.Client_MD_ID__c != null && c.MD_ID__c == null ){
                c.MD_ID__c = c.Client_MD_ID__c;
            }
        }
    }

    public static void setContactAccountByCaseIds(List<Contact> newRecords){
        Set<String> caseIds = new Set<String>();
        Map<String,Id> caseIDMap = new Map<String,Id>();

        for(Contact c : newRecords){

            if(c.MD_ID__c != null && c.Case_ID__c != null){
                caseIds.add(c.Case_ID__c);
            } 
        }
        List<Account> accounts = [SELECT Id, Case_ID__c FROM Account WHERE Case_ID__c in: caseIDs];
        for(Account a : accounts){
            caseIDMap.put(a.Case_ID__c, a.Id);
        }
        for(Contact c : newRecords){
            if(c.MD_ID__c != null && c.Case_ID__c != null && c.AccountId == null && caseIDMap.containsKey(c.Case_ID__c)){
                c.accountId = caseIDMap.get(c.Case_ID__c);
            } 
        }
    }
    
    public static void insertSubsidiaryAccounts(List<Contact> newRecords) {
        
        for(Contact ct : newRecords) {
            if(ct.RecordTypeId == contactProviderRT) {
                AccountRelationService.insertSubsidiaries(ct);
            }
        }
        
        if(AccountRelationService.relatedContacts.size() > 0) {
            Database.insert(AccountRelationService.relatedContacts, false);
        }
    }

 
 Hi Team
 I have a question as I cannot see all the fields for selection of an related object in the related list.
Which fields of an object are available in available fields list of a related list?
  • April 07, 2022
  • Like
  • 0
Name- aws_WScallout
url - https://servicename.amazonaws.com
Identity Type - Named Principal
Authentication Protocol - AWS Signature Version 4
AWS Access Key ID - ******
AWS Secret Access Key - ********
AWS Region - us-east-1
AWS Server- executea
Generate Authorization Header - true 
 
String token ='abcdefghijkl'; (say)
 HttpRequest req = new HttpRequest();
 req.setEndpoint('callout:aws_WScallout/alpha/plan/5?Source=Ops&localen=NA');
 req.setMethod('GET');
 Http http = new Http();
 HTTPResponse res = http.send(req);
 while (res.getStatusCode() == 302) {
           res.setEndpoint(res.getHeader('Location'));
           res = new Http().send(req);
       }
 System.debug(res.getBody());

I have to add x-amz-access-token which I get programmatically from another webservice. without adding error I am getting.
DEBUG|{"message": "Missing required request parameters: [x-amz-access-token]"}
how should I add to this callout?
I tired doing this 
  • req.setHeader('x-amz-access-token', token); 
  • req.setHeader('Authorization', EncodingUtil.base64Encode( Blob.valueof('x-amz-access-token'+ token)));
  • req.setHeader('x-amz-access-token', EncodingUtil.base64Encode(Blob.valueof(token)));

I get this error
DEBUG|{"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method..."}
  • December 06, 2019
  • Like
  • 0
I displaying data in a table using <apex: repeat> and  Lightning Design System in a visualforce page. And using data tables.js I am paging the data. pagination numbers, instead of appearing on bottom right , horizontally. is displays vertically. Any inputs?
pagination issue with Datatables.js
  • November 21, 2018
  • Like
  • 0
I have a page that iterates a list object to display the records. Once clicked on save, I updated the same list with new values and debug logs shows the update list but output panel is not rerender'ed and I dont see updated list on VF page.
 
<apex:outputLabel >A  </apex:outputLabel>
        <apex:inputfield id="idAText" value="{!ttlookup.A}" />
      <apex:inputCheckbox id="checkBoxTMId" value="{!Acheckbox}"/>
      <apex:outputLabel > Check if you want to clear all values 
</apex:outputLabel>

    <apex:commandButton id="btnSave" value=" Save " action="{!Save}" reRender="idPanel" />

 <apex:outputPanel ID = "idPanel">
        <div class="container">   
            <table>
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th> 
                        </tr>
                    </thead>
                    <tbody>
                        <apex:repeat value="{!ryList}" var="tt">
                                <tr>
                                    <td>{!tt.name}</td>
                                    <td>{!tt.Type__c}</td>
                                </tr>
                        </apex:repeat>
                    </tbody>
            </table>

Controller Method :
 
public void save(){
    Boolean noUpdateFlag = false;
    for(MyObjec ttry: ryList){
        if(ttlookup.A !=null){
            noUpdateFlag = true;
            ttry.name = ttlookup.A;
        }

        if(Acheckbox){
            noUpdateFlag = true;
            ttry.name = null;
        }

    }
    system.debug(ryList[0].B + ' noUpdateFlag '+noUpdateFlag);
    try{
        if(noUpdateFlag){
            update ryList;
            ApexPages.addmessage(new Apexpages.message(apexpages.severity.CONFIRM, 'records are saved.'));
        }
        else
            ApexPages.addmessage(new Apexpages.message(apexpages.severity.Info, 'no value entered '));
    }catch(Exception ex){
        System.debug(ex);
        ApexPages.addmessage(new Apexpages.message(apexpages.severity.Error, 'Something went wrong'));
    }

}

and moreover when I add reRender = "idPanel" my apex messages are not displayed. I have no clue why :( any inputs please?
  • October 22, 2018
  • Like
  • 0
I have gotten all the way to Create a Trigger, and I get:

Couldn’t find the record named 'Nina Simone' with Email 'nsimone@test.com'. Please double check the instructions.

When I try to create the candidate, I get:

CreateContact: execution of AfterInsert caused by: System.QueryException: List has more than 1 row for assignment to SObject Class.CreateContactFromCan.createContact: line 5, column 1 Trigger.CreateContact: line 5, column 1   

 
String query = 'FIND \'*' + searchString + '*\' IN ALL FIELDS RETURNING Ticket__C (Region__r.name, Manager__c, Manager__r.name, Name, Notes__c), user(id,Name)'; 
 I am searching with user name and results are zero.
 Aim: when a string is entered, it should match with any of the fields of ticket and display the results. with the above query, it will match only with Ticket.name and shows zero results when i am searching for the user.name.  any inputs please
  • October 16, 2018
  • Like
  • 0
Hi, I have the requirement like this. Say I have a Visualforce page which has '<apex:page> This is a new page </apex:page>'. Then I want an audio player on that page which will play this exact statement "This is a new page." Is this possible to be done in Apex? Or through Javascript on Apex? If anyone has done this or know about how it can be implemented, please share the relevant steps and code. 
  • January 19, 2017
  • Like
  • 0
Hello everyone. 
I am in need of some help creating a S-Control.  I am the Admin for my company but do not have much programming experience.  I am trying to create a process in the opportunity tab that will create a new record in in a related custom object when the user saves a new opportunity.  The new record on the custom (related) object will contain data from 3 fields in the opportunity.  I was told that an S-Control can achieve this.  If anyone can lead me in the right direction, it would be greatly appreciated. 

Thank you in advance,
sfmoose