• Santosh Reddy9989
  • NEWBIE
  • 140 Points
  • Member since 2016

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 10
    Questions
  • 28
    Replies
Could someone help me write a test class for this:
 
private final Facturatie__c a;

    public attachPDF(ApexPages.StandardController standardPageController) {
        a = (Facturatie__c)standardPageController.getRecord(); 
      
    }    
    Facturatie__c  currentRecord = [SELECT id, Accountname__r.Name FROM Facturatie__c WHERE id = :ApexPages.currentPage().getParameters().get('id')];

    public PageReference attachPDF() {

        PageReference pdfPage = Page.Factuur2PDF;
        pdfPage.getParameters().put('id',a.id);
          
        Blob pdfBlob = pdfPage.getContent(); 
        
        Attachment attach = new Attachment(parentId = a.id, Name = 'Factuur ' + '-' + currentRecord.Accountname__r.Name +'-'+ date.today().format() +'.pdf', body = pdfBlob); 
        insert attach;
        
        PageReference pageWhereWeWantToGo = new ApexPages.StandardController(a).view(); 
        pageWhereWeWantToGo.setRedirect(true); 
        return pageWhereWeWantToGo;
    }
}

 
Hi Guys,

Need help in coverage.I have written test class for below batch apex biut was able to achieve only 50% coverage.Pls help me to get 100% coverage.

global class BatchClassexample implements Database.Batchable<sObject> {
    
    global String query = 'SELECT Id,Name FROM Account where name=:filter ';
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        system.debug('inside methiod----');
        String filter='bBVINES';
        return Database.getQueryLocator(query);
    }
    global void execute(Database.BatchableContext BC, List<Account> scope)
    {
        //User u=[SELECT username from user where profileid='00e28000000sxOR'];
        system.debug('inside method 1---');
        for(Account a : scope)
        {
            a.Name = a.Name + 'By bhuvanBam';
        }
        system.debug(scope);	
        update scope;
        //system.runAs(u){}
    }
    global void finish(Database.BatchableContext BC) {
    }
}


//Test class
@isTest
   public class BatchClassexampleTestClass {
        public static testMethod void testRunAs(){        
        String filter='bBVINES';
        Test.startTest();
        BatchClassexample BC=new BatchClassexample();
         Account a=new Account(name='bBVINES');
            insert a;
            List<Account> alist=[Select name from Account where name like '%bBVINES%'];
            for(Account afor:alist){
               afor.name=afor.name+'Bhuvanbam';
            }
            update alist;
            User u=[SELECT username from user where profileid='00e28000000sxOR'];
           system.runAs(u){} 
            DataBase.executeBatch(BC,200);
           Test.stopTest();
       
        
       } 
          }

 
global class TechMDeletion implements Database.Batchable<sObject>
{   
    
    
  
    global Database.QueryLocator start(Database.BatchableContext bc)
    {
        date d=system.today().adddays(-30);        
        return Database.getQueryLocator([Select id from TechM__c where CreatedDate =:d]);


  
    } 
    
    
    
    global void execute(Database.BatchableContext BC, list<sObject> scope)
    {     
    system.debug('records fetched are'+scope);
        
 
        
            delete scope;   
            DataBase.emptyRecycleBin(scope); 
    }
    
    
    global void finish(Database.BatchableContext BC) 
    {                 
        
        
       
    }
}
Hi all,
I want to show the fields when a check box is check and hide the fields when the checkbox is uncheck. Below is my vfpage and extenstion class.
<apex:page standardController="Account" extensions="constructor">
<apex:form >
<apex:pageBlock Title="Account Checkbox Test">
<apex:pageBlockSection id="Selected_PBRS">
<apex:inputCheckbox value="{!account.Port__c}" id="checkedone">
<apex:actionSupport event="onchange"  rerender="Fieldrender" action="{!Fieldupdate}"/>
                </apex:inputCheckbox>
    <apex:inputText value="{!account.Score__c}"  rendered="{!field}" id="Fieldrender"/>
    <apex:inputText value="{!account.Review__c}" rendered="{!field}" />
</apex:pageBlockSection>

</apex:pageBlock>
</apex:form>
</apex:page>
public class constructor{

    public Boolean Portfolio{get; set;}
    public Boolean field {get;set;}
    public string Score {get;set;}
     public string Review {get;set;}
public constructor(ApexPages.StandardController controller) { } 
Public constructor() {
    field=true;
}

public void Fieldupdate{
     If(account.Port__c == true){
           field=false;
     }else{
            field=true;
      }
}
    
}
I have been facing the error as below.

Error: Compile Error: unexpected token: 'If' at line 13 column 5

Can anyone help me over here.
Thanks in advance.
Regrads,
mac.

 
There are 2 pricebooks in our org. I have created one List Button using this URL:
/_ui/sales/quote/lineitem/ChooseQuotePricebook/e?id={!Quote.Id}

I am able to change the pricebook If quote didn't contain any lineitems. But when quote already have lineitems then i am getting below error.

Unable to Access Page
The value of a parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information. 


Thanks,
Santosh Reddy
Hi,

query : Select Id, Name, Email, Account.Name, Account.Industry from Contact


For Id, name and Email fields, we use below code for FLS check

 SObjectType childobje = Schema.getGlobalDescribe().get('Contact'); 
 childobje.getDescribe().fields.getMap().get('Name').getDescribe().isAccessible();
 childobje.getDescribe().fields.getMap().get('Email').getDescribe().isAccessible();


if i use childobje.getDescribe().fields.getMap().get('Account.Industry').getDescribe().isAccessible() then i am getting "NullPointerException de-reference a null object" exception.

How to check the FLS for Account.Industry from contact object ??????? 

Thanks,
Santosh Reddy
Hi, This is santosh.
I am system adimistrator.
I have removed read access of  Account Name(AccountId) field from Contact Object. As shown in below image.
User-added image

I have used below the code for Lightning component controller.

global with sharing class GenericCmpController 
{

    @AuraEnabled
   public static DynamicBindingWrapper getRecords(String objectName,........... )
   {

     SObjectType childobje = Schema.getGlobalDescribe().get('Contact');
     
     system.debug('Field FLS = ' +  childobje.getDescribe().fields.getMap().get('AccountId').getDescribe().isAccessible());
    
     ....................................
     ....................................
   }
}

When  i check the debug log 

Field FLS = true 


If i run the same code  in developer console i am getting 

Field FLS = false ;

How did i get isAccessible() value True for AccountId , After mentioned "With sharing" in lightning controller  ?

Whyam I getting different results for developer console and Lightning controller (With sharing) ??
 
Please clarify.

Thanks,
Santosh Reddy
Iam using system adimin profile and we have already created around 3000+ contactRole records on Account.
But today,   getting below error in production when we try to create new contactRole on Account.

Insufficient Privileges
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. For more information, see Insufficient Privileges Errors.

 
Here's my component code:

<aura:component implements="force:lightningQuickAction,force:hasRecordId" access="global"  >
<ui:inputText aura:id="PlanName" label="Plan Name" required="true" change="{!c.onChange}"/>   
<ui:inputnumber aura:id="Amount" label="Amount" required="true" change="{!c.onChange}" />
<lightning:button label="Add New Card"   aura:id="newcard"    onclick="{!c.chargefun}"  />  
</aura:component >
   
component.js code :

({
 onChange : function(component, event, helper)
    {        
            var selectCmp = event.getSource();
          selectCmp.set("v.errors",null);
    },

chargefun : function(component,event,helper)
{
  var PlanName = component.find("PlanName").get("v.value");
  var amt = component.find("Amount");
  var amount = amt.get("v.value");
   if($A.util.isEmpty(amount) ||  $A.util.isEmpty(PlanName ))
   {
       if ($A.util.isEmpty(amount))
           {
             amt.set("v.errors", [{message:"Please Enter Value"}]);
           }
           if ($A.util.isEmpty(PlanName))
           {
             component.find("PlanName").set("v.errors", [{message:"Please Enter Value..."}]);
           }
   },

})


In above code,  event.getSource() was not working for <ui:inputnumber>. So iam not able to remove error message.
Salesforce is requesting a scan report of the REST API as a part of security review submission.

how to generate scan report of 'https://api.stripe.com'  REST API endpoint by using either of the following scanning tools:  ZAP, BURP or Chimera.

Thanks,
Santosh Reddy
I am integrating Stripe Payment Gateway  in salesforce lightning bundle.
Ref : https://stripe.com/docs/stripe.js
How to write "stripeResponseHandler" function in  Lightning controller.js

/*LightningController.js*/

({
   
   Stripetoken2: function(component,event,helper)
    {
        Stripe.setPublishableKey('pk_test_n1KbUbq0OQhNYgxhVFv71bMN');
       
        var cardNumber = component.find("number").get("v.value");
        var cardcvv = component.find("cvv").get("v.value");
        var cardexp_month = component.find("expiry-month").get("v.value");
        var cardexp_year = component.find("expiry-year").get("v.value");

        Stripe.card.createToken({
                                      number: cardNumber,
                                      cvc: cardcvv,
                                      exp_month: cardexp_month,
                                      exp_year: cardexp_year
                                   }, stripeResponseHandler​​);  
    },
})


Can any one help, how to write code for stripeResponseHandler function in controller.js
I tried below code but not working.

 var stripeResponseHandler = function(status, response) 
                                    {
                                     if (response.error) 
                                    { 
                                         alert(response.error.message);
                                        
                                     }
                                     else
                                     {
                                         alert(response.id);
                                         
                                     }  
                                    };    
I developed a post installation script using  InstallHandler interface for a managed package which creates a scheduled job to run batch apex. In batch apex iam fetching transaction status if it is settled then iam sending email to customer with pdf attachment. But iam getting empty pdf in email attachment (no errors).
If i scheduled that job manually (without using post installation script), it is working fine.
For generating pdf, iam using below code
PageReference pdf = new PageReference('/apex/pdfpage?id='+aid);
body = pdf.getcontentAsPdf();
Hi,

Force.com Security Source Code Scanner treating getter method as test method in test class and giving Quality Issues (Query: Test Methods With No Assert).
 
sample code :

@isTest
public class StripePlanTests {

    public static String testData_getPlan {
        get {
            return '{'+
            '  "interval": "year",'+
            '  "name": "Cirrus Insight Annual Subscription",'+
            '  "created": 1354825845,'+
            '  "amount": 0,'+
            '  "currency": "usd",'+
            '  "id": "CI_ANNUALLY",'+
            '  "object": "plan",'+
            '  "livemode": false,'+
            '  "interval_count": 1,'+
            '  "trial_period_days": null,'+
            '  "statement_description": null'+
            '}';
        }
    }
    public static Map<String, String> payload {
        get{
            Map<String, String> payload1 = new Map<String, String>();
            payload1.put('interval','year');
            payload1.put('name','Cirrus Insight Annual Subscription');
            payload1.put('amount','0');
            payload1.put('currency','usd');
            payload1.put('id','CI_ANNUALLY');
            payload1.put('interval_count','1');
            payload1.put('trial_period_days','null');
            return payload1;
        }
    }
}

User-added image
how to assign custom setting value  to lookup field of object in process builder (field update) ?
There are 2 pricebooks in our org. I have created one List Button using this URL:
/_ui/sales/quote/lineitem/ChooseQuotePricebook/e?id={!Quote.Id}

I am able to change the pricebook If quote didn't contain any lineitems. But when quote already have lineitems then i am getting below error.

Unable to Access Page
The value of a parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information. 


Thanks,
Santosh Reddy
Hi,

query : Select Id, Name, Email, Account.Name, Account.Industry from Contact


For Id, name and Email fields, we use below code for FLS check

 SObjectType childobje = Schema.getGlobalDescribe().get('Contact'); 
 childobje.getDescribe().fields.getMap().get('Name').getDescribe().isAccessible();
 childobje.getDescribe().fields.getMap().get('Email').getDescribe().isAccessible();


if i use childobje.getDescribe().fields.getMap().get('Account.Industry').getDescribe().isAccessible() then i am getting "NullPointerException de-reference a null object" exception.

How to check the FLS for Account.Industry from contact object ??????? 

Thanks,
Santosh Reddy
Why roll up summary is for master details fields not for lookup fields?
Iam using system adimin profile and we have already created around 3000+ contactRole records on Account.
But today,   getting below error in production when we try to create new contactRole on Account.

Insufficient Privileges
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. For more information, see Insufficient Privileges Errors.

 
Here's my component code:

<aura:component implements="force:lightningQuickAction,force:hasRecordId" access="global"  >
<ui:inputText aura:id="PlanName" label="Plan Name" required="true" change="{!c.onChange}"/>   
<ui:inputnumber aura:id="Amount" label="Amount" required="true" change="{!c.onChange}" />
<lightning:button label="Add New Card"   aura:id="newcard"    onclick="{!c.chargefun}"  />  
</aura:component >
   
component.js code :

({
 onChange : function(component, event, helper)
    {        
            var selectCmp = event.getSource();
          selectCmp.set("v.errors",null);
    },

chargefun : function(component,event,helper)
{
  var PlanName = component.find("PlanName").get("v.value");
  var amt = component.find("Amount");
  var amount = amt.get("v.value");
   if($A.util.isEmpty(amount) ||  $A.util.isEmpty(PlanName ))
   {
       if ($A.util.isEmpty(amount))
           {
             amt.set("v.errors", [{message:"Please Enter Value"}]);
           }
           if ($A.util.isEmpty(PlanName))
           {
             component.find("PlanName").set("v.errors", [{message:"Please Enter Value..."}]);
           }
   },

})


In above code,  event.getSource() was not working for <ui:inputnumber>. So iam not able to remove error message.
Could someone help me write a test class for this:
 
private final Facturatie__c a;

    public attachPDF(ApexPages.StandardController standardPageController) {
        a = (Facturatie__c)standardPageController.getRecord(); 
      
    }    
    Facturatie__c  currentRecord = [SELECT id, Accountname__r.Name FROM Facturatie__c WHERE id = :ApexPages.currentPage().getParameters().get('id')];

    public PageReference attachPDF() {

        PageReference pdfPage = Page.Factuur2PDF;
        pdfPage.getParameters().put('id',a.id);
          
        Blob pdfBlob = pdfPage.getContent(); 
        
        Attachment attach = new Attachment(parentId = a.id, Name = 'Factuur ' + '-' + currentRecord.Accountname__r.Name +'-'+ date.today().format() +'.pdf', body = pdfBlob); 
        insert attach;
        
        PageReference pageWhereWeWantToGo = new ApexPages.StandardController(a).view(); 
        pageWhereWeWantToGo.setRedirect(true); 
        return pageWhereWeWantToGo;
    }
}

 
Hi Bro,

This is my requirement i want display the records on Account object,whenever select the value of pick list in visualforce page  .Here i am attaching my page and class. i am  thinking Action is not working..pls help me 
PAGE:

<apex:page standardController="Account" extensions="fetchdisplayrecords">
      <apex:form >
          <apex:pageBlock id="Block" >
              <div style="width:700px; margin:0 auto;">
              
                
                      
                      <apex:outputText value="List of Contacts : "/>
                      <apex:selectList value="{!selectedItemValue}" multiselect="false" size="1">
                     <apex:actionSupport event="onchange"  action="{!changeRec}" status="thestatus" reRender="theform" />
                     <apex:selectOptions value="{!items}"/>
                 </apex:selectList>
                 </div>
                 
                  
              
          </apex:pageBlock>
          <apex:actionStatus id="thestatus" startText="Please Wait It's Loading....."></apex:actionStatus>
          <apex:detail subject="{!recId}" rendered="{!if(recId!=null,true,false)}" relatedList="false"/>
      </apex:form>
</apex:page>







Class 



Public class fetchdisplayrecords
{
public Account Acc {get; set;}
public string selectedItemValue{get;set;}
public id recId {get;set;}
public fetchdisplayrecords(ApexPages.StandardController controller)
 {
   //acc = [SELECT Name, AccountNumber FROM Account limit 5];
 }
     public List<selectoption> getitems()
     {
     List<Selectoption> opts = new List<Selectoption>();
        opts.add(new selectoption('','--None--'));
        for(Account Acc: [Select Id,Name From Account limit 10]){   
                opts.add(new selectoption(Acc.Id,Acc.Name));
        }
   return opts;
     }
     
     public pageReference changeRec()
     {
     if(selectedItemValue!=null&&selectedItemValue!='')
       {
          recId = selectedItemValue;  
        }
        else recId = null;
        return null;
     }
}



Note: Values are came into the picklist..after selecting the value i didn't recive the records..Could you pls help me..let me know where is mistake.

Thanks ,
Chanti
Is it possible to display internal salesforce article on public site?

If yes then how?
Even I have tried to make a visual force page and have tried to display data thru it but it is not getting displayed on site(while internally everything is visible on that page but not site) . So if anyone knows how to give access to profile of site then please let me know.
Any other solutions are also welcome.
  • February 17, 2017
  • Like
  • 0
Hi all,

I am trying to create a Visualforce page that is a form, combining both merge fields pulled from the initiating Opportunity page and text fields to be completed by the User.  This form will then be emailed to a specific email address.  I would then set this Visualforce page as a button on the Opportunity page.  I have been able to get the Visualforce page coding to work, but cannot get the Apex code / controller to send the email.  I am not experienced in developing, so please excuse my terrible formatting and improper terminology!!

Thank you for your help!!

VISUALFORCE PAGE:
<apex:page standardController="Opportunity" extensions="SendTCSRequest">
    <apex:messages />
    <img src="https://glu26xod9g-flywheel.netdna-ssl.com/wp-content/themes/cloudtp2016/img/Cloud_Technology_Partners_Logo.svg" alt="CTP Logo" height="100" width="200"></img>
    <apex:pageblock >
            <style>
            body .bPageBlock .pbBody .red .pbSubheader{
                background-color:#c00000; font-size:150%;
            }
            body .bPageBlock .pbBody .grey .pbSubheader{
                background-color:#c0c0c0; font-size:150%;
            }
            body .bPageBlock .pbBody .grey .pbSubheader h3{
                color:#000; font-size:150%;
            }
        </style>
    <apex:outputPanel styleClass="grey" layout="block">
    <apex:pageblocksection title="Request to Engage a TCS Member on Opportunity - {!Opportunity.Name}:">
        <apex:form >
             <br /><br />
                <b>Account: </b> <apex:outputfield value=" {!Opportunity.Account.Name}"/>     
             <br /><br />
                <b>Type: </b><apex:outputfield value=" {!Opportunity.Type}"/>     
             <br /><br />
                <b>Opportunity Name: </b><apex:outputfield value="{!Opportunity.Name}"/>
             <br /><br />
                <b>Owner: </b><apex:outputfield value="{!Opportunity.Owner.Name}"/>
             <br /><br />
                <b>CTP Forecast Category: </b><apex:outputfield value="{!Opportunity.CTP_Forecast_Category__c}"/>
             <br /><br />
                <b>Stage: </b><apex:outputfield value="{!Opportunity.StageName}"/>
             <br /><br />
                <b>Amount: </b><apex:outputfield value="{!Opportunity.Amount}"/>
             <br /><br />
                <b>Close Date: </b><apex:outputfield value="{!Opportunity.CloseDate}"/>
             <br /><br />
                <b>Link: </b> <apex:outputlink value="{!LEFT($Api.Partner_Server_URL_140,FIND('.com',$Api.Partner_Server_URL_140)+4)+Opportunity.Id}" target="_blank">{!Opportunity.Name}</apex:outputlink>
             <br /><br />
        </apex:form>
    </apex:pageblocksection>
    </apex:outputPanel>
    <apex:outputPanel styleClass="red" layout="block">
    <apex:pageblocksection title="Sales Rep to fill out specifics:">
        <apex:form >    
            <br /><br />
                <b>Cloud Platform:</b><apex:outputfield value="{!Opportunity.Cloud_Platform__c}"/>
            <br /><br /> 
                <apex:outputLabel value="Industry Vertical:" for="Industry Vertical"/><br />    
                <apex:inputTextarea required="true" id="IndustryVertical" rows="1" cols="80"/>
            <br /><br /> 
                <apex:outputLabel value="Project Location:" for="Project Location:"/><br />    
                <apex:inputTextarea required="true" id="ProjectLocation" rows="1" cols="80"/>
            <br /><br /> 
                <apex:outputLabel value="Opportunity Information:" for="Opportunity Information:"/><br />    
                <apex:inputTextarea required="true" id="OpportunityInformation" rows="10" cols="80"/>
            <br /><br /> 
                <apex:outputLabel value="Has a TCS person worked with this client before?:" for="HistoricalTCS"/><br />    
                <apex:inputTextarea required="true" id="HistoricalTCS" rows="1" cols="80"/>
            <br /><br /> 
                <apex:outputLabel value="Additional Information:" for="Additional Information:"/><br />    
                <apex:inputTextarea required="true" id="AdditionalInformation" rows="10" cols="80"/>         
            <br /><br /><br />
    <apex:commandButton value="Send to TCS" action="{!send}" />
        </apex:form>
    </apex:pageblocksection>
    </apex:outputPanel>
    </apex:pageblock>
</apex:page>

APEX CONTROLLER
public class SendTCSRequest {

public Id oppId;

    public SendTCSRequest(ApexPages.StandardController controller) {
        opp = [SELECT Id, Account.Name, Type, Name, Owner.Name, CTP_Forecast_Category__c, StageName, Amount, CloseDate, Cloud_Platform__c FROM Opportunity
            WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
}

    public PageReference send() {
        return null;
    }


    public String emailTo {get; set;}
    public String emailBody {get; set;}
    public String subject {get; set;}
    public String body {get; set;}
    public String response {get; set;}
     
    private opportunity opp; 
    
    public Opportunity getOpportunity(){
    return opp;
    }   

    {
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(new String[] {'TCS-Engagement-Request@cloudtp.com'});
        mail.setReplyTo('bill.peldzus@cloudtp.com');
        mail.setSenderDisplayName('Owner.Name');
        mail.setSubject('Request for TCS to Engage on an Opportunity');
        mail.saveAsActivity = true;
        mail.sethtmlBody(emailBody);


        try
        {
            Messaging.SendEmailResult[] resultMail = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
            if(resultMail[0].isSuccess())      
                response = 'Sent!';
            else
            {
                response = resultMail[0].getErrors().get(0).getMessage();
            }
        }
        catch(System.EmailException ex)
        {
            response = ex.getMessage();
        }  

    }
    
}

 
Hi Guys,

Need help in coverage.I have written test class for below batch apex biut was able to achieve only 50% coverage.Pls help me to get 100% coverage.

global class BatchClassexample implements Database.Batchable<sObject> {
    
    global String query = 'SELECT Id,Name FROM Account where name=:filter ';
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        system.debug('inside methiod----');
        String filter='bBVINES';
        return Database.getQueryLocator(query);
    }
    global void execute(Database.BatchableContext BC, List<Account> scope)
    {
        //User u=[SELECT username from user where profileid='00e28000000sxOR'];
        system.debug('inside method 1---');
        for(Account a : scope)
        {
            a.Name = a.Name + 'By bhuvanBam';
        }
        system.debug(scope);	
        update scope;
        //system.runAs(u){}
    }
    global void finish(Database.BatchableContext BC) {
    }
}


//Test class
@isTest
   public class BatchClassexampleTestClass {
        public static testMethod void testRunAs(){        
        String filter='bBVINES';
        Test.startTest();
        BatchClassexample BC=new BatchClassexample();
         Account a=new Account(name='bBVINES');
            insert a;
            List<Account> alist=[Select name from Account where name like '%bBVINES%'];
            for(Account afor:alist){
               afor.name=afor.name+'Bhuvanbam';
            }
            update alist;
            User u=[SELECT username from user where profileid='00e28000000sxOR'];
           system.runAs(u){} 
            DataBase.executeBatch(BC,200);
           Test.stopTest();
       
        
       } 
          }

 
Hi All, I am calling a middleware system form apex, before calling the webservice Ist I set connection with the system. In this way there are 3 http callout in one apex transation. In my 1st callout which returns me PingToken, m getting callout read time out error. I got to know that I can increase the time out Limit but it can be max 120 sec in whole tranation. default is 10 sec, How I should decide to increase time limit of my first http request in my apex transaction?


Thanks
Ranu
I am trying to create a trigger on Contact. When a custom field Company_Name__c on Contact is populated the trigger should create an Account if it does not exist. Also the AccountId should be updated on the Contact record
I was able to do it with simple trigger code but noticed that there is a limit (Number of Query Rows: 50000). So I started trying using Queueable APEX but ran into this issue
I am not able to update the Contact records. I see the AccountId value in the debug logs but the Contact record is not updated with AccountId after the Trigger completed
Can you suggest how this can be achieved

Below is the code I am using

CreateAccountFromCompanyTrigger

trigger CreateAccountFromCompanyTrigger on Contact (before insert, after insert) {
    If(Trigger.isBefore && Trigger.isInsert)
    {
       
    //ContactTriggerClass.InsertContacts(Trigger.new); 
    ContactTriggerClass CreateContactJob = new ContactTriggerClass(Trigger.new);     
    System.enqueueJob(CreateContactJob);
               
    }//If
}

ContactTriggerClass

public class ContactTriggerClass implements Queueable  {
  
    //public List<Contact> TriggeredContactList = new List<Contact>();
    public List<Contact> TriggeredContactList;
   
    public ContactTriggerClass(List<Contact> ContactList){
        TriggeredContactList = ContactList;
       
    }//mainmethod
   
    public void execute(QueueableContext context) {
    List<Account> AcctsToCreate = new List<Account>();
    Map<String, Account> AllAccountsMap = new Map<String, Account>();
       
        for(Account acct : [Select Id, Name from Account]){
            AllAccountsMap.put(acct.Name, acct);
           
        }
   
    System.debug('AllAccountsMap:' +AllAccountsMap.size());
       
        Set<String> CompanyNameSet = new Set<String>();
        for(Contact cntct : TriggeredContactList ){
            if(!AllAccountsMap.containsKey(cntct.Company_Name__c))
                CompanyNameSet.add(cntct.Company_Name__c);
        }   
       
         if(CompanyNameSet.size() > 0){
            for(String CompanyName : CompanyNameSet)
            AcctsToCreate.add(new Account(Name = CompanyName));
        insert AcctsToCreate;
        }
       
        if(AcctsToCreate.size() > 0)
        {
            for(Account acct : AcctsToCreate)
                AllAccountsMap.put(acct.Name, acct);
        }
        System.debug('UpdatedAccountsMap' +AllAccountsMap.size()); 
       
        for(Contact cntct : TriggeredContactList){
            cntct.AccountId = AllAccountsMap.get(cntct.Company_Name__c).Id;
            System.debug('cntct record:' +cntct +cntct.AccountId);
        }
       
       
}//execute
  
   
   
}//class
 
Hello All,

I have run code scanner tool on my apex class and Visual force page. It give me FLS Create and FLS Update Issues.
I have solved these issues as per mention following URL

https://developer.salesforce.com/page/Testing_CRUD_and_FLS_Enforcement
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_perms_enforcing.htm

Again I have run code scanner tool on my apex class and Visual force page. It gives me again FLS Create and FLS Update Issue.
Let me know, if anything I miss

Following are the sample code

Boolean isContFirstNameUpsertable = Schema.sObjectType.Contact.fields.FirstName.isCreateable() &&
                                Schema.sObjectType.Contact.fields.FirstName.isUpdateable();
Boolean isContLastNameUpsertable = Schema.sObjectType.Contact.fields.LastName.isCreateable() &&
                                Schema.sObjectType.Contact.fields.LastName.isUpdateable();

List<Contact> lstContact = new List<Contact>();
if(isContFirstNameUpsertable && isContLastNameUpsertable) {
    for(AgentWrapper aw : scope) {
        Contact c = new Contact(
                                    FirstName=aw.FirstName,
                                    LastName=aw.LastName);
        lstContact.add(c);
    }
    if(lstContact.size() > 0) {
        upsert lstContact;
    }
}

Thanks in Advance

Public with sharing class MTX_SupplierDelete
{

    public Integer NoOfDays { get; set; }

public List<MTX_SupplierOracleAP__c> supplierList {get; set;}


public void DeleteSupplier()
   {
     Date dt = Date.today() - NoOfDays ;
     supplierList = Database.query('Select id from MTX_SupplierOracleAP__c where ProcessDate__c <=:dt');
     system.debug('Records fetched by given date'+ dt);
     
     system.debug('Fetched records size is'+ supplierList.size());
     system.debug('Supplier records fetched'+ supplierList);
     delete supplierList;

   }   

}

My Question is this

I have a sObject name "object1", having one profile name "profile1" which have all permitionss (create, edit, delete, view, viewAll, modifyAll) for sObject (object1), now I assigned that profile to User1, user2. Now I wants to assign same profile (profile1) to user3, but the condition is this user3 only have a create permition, how would I achive this. I know by permition set we can add new permitions but we can not degrade permitions.

Please reply

Hi All,

I am a newbie to Lightning component Development.

I have written a lightning component, which holds Text Input, and a button.
When User enters some text in the text field, by clicking a button. I am calling a javascript controller, then to Javascript Handler, then to Apex Controller. I am searching and returning the result to handler, to javascript handler and then to component attribute values.

I am setting Response to Component attribute in Handler.

I am not getting the response in UI. When I debugged using Lightning Inspector - Chrome Extensions, Actions are successful, and I am getting result in the attributes.

Please let me know, whether i am missing anything.

Thanks in advance.