• Sandeep Yadav
  • NEWBIE
  • 94 Points
  • Member since 2017
  • Salesforce Developer


  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 18
    Questions
  • 44
    Replies
Apex class
-------------
public class StringStack {

      private List<String> stack;

    public StringStack()
    {
         stack = new List<String>();

    }

    public void push(String s)
    { 
        stack.add(s); 
    }
    public String pop() 
    {
       
    return stack.remove( lastItemIndex );
    }
    public String peak() 
    {

        return stack.get( lastItemIndex );

    }

 
    public Boolean isEmpty() 
    { 
        return stack.isEmpty();
    }
     

    // Helper Property

    private Integer lastItemIndex
    {
        get 
        { 
            return stack.size() - 1;
            }
    }

}



Test clas
------------
@isTest
public class TestStringStack 
 {
public static testmethod void StringStackcheck()
{
    //Instantiate a StringStack.

    StringStack stack = new StringStack();
 // Set up some test data.

    String bottomString = 'Bottom String';
    String middleString = 'Middle String';
    String topString = 'Top String';

      // Call the push() method with multiple objects

    stack.push(bottomString);

    stack.push(middleString);
    stack.push(topString);

    // Verify that the 'top' object is the object we expected

    String peakValue = stack.peak();

    System.assertEquals(topString, peakValue);

    // Verify that the order of the objects is as we expected
    String popValue = stack.pop();
    System.assertEquals(topString, popValue);
    popValue = stack.pop();
    System.assertEquals(middleString, popValue);
    popValue = stack.pop();
    System.assertEquals(bottomString, popValue);
    System.assert(stack.isEmpty());

}
 }

Hi All,

whenever i upload an attachment to account record, Custom Access setting should be checked bydefault for making file visible to customer portal user.

User-added image

I have Used trigger also for this setting on file(ContentDocumentLink) record:
SharingType  = 'V';
Visibility = 'AllUsers';

Any help would be much appreciated.

Regards
Sandeep

I Have Installed Financial Service Cloud Package. Getting this error while creating this task when i give some contcats to Name Field.

Any Help would be appreciatable.User-added image
Hey Everyone,

Getting this error on lead conversion:

Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Status]: [Status]

I have also checked that LeadStatus is also set as Qualified.

Please help me there.
Hi All,

I have tried Pre-Chat for using Aura Component provided by salesforce (below link ) but unable to add T&C wording with a
checkbox.

https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_lightning_components_prechat_sample_aura.htm

is it possible ?
Any help would be great.

Best
Sandeep
Want to access custom object field values in email template.
Here is what i did-
 
public static void sendCreationEmail(Service_Request__c srNew){
        string ldOwnerMail = srNew.Owner.Email;
        Messaging.SendEmailResult[] results;
        if(ldOwnerMail != null && ldOwnerMail != ''){
            Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
            message.setToAddresses(new String[] {ldOwnerMail});
            message.setTemplateId([select id from EmailTemplate where DeveloperName='Service_Request_Creation'].id);
            message.setSaveAsActivity(false);
            message.setWhatId(srNew.Id);
            message.setTreatTargetObjectAsRecipient(false);
            message.setTargetObjectId('01I6g000000shKzEAI');// Id of custom Object.
            
            results = Messaging.sendEmail(new Messaging.SingleEmailMessage[]{message});
        }
    }

Any Help on this ?
Here is what i have done...
Messaging.SendEmailResult[] results;
Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
message.setToAddresses(new String[] {ldOwnerMail});
message.setTemplateId([select id from EmailTemplate where DeveloperName='LeadsNewassignmentnotificationSAMPLE'].id);
message.setTargetObjectId(lead.OwnerId);

message.setSaveAsActivity(false);
results = Messaging.sendEmail(new Messaging.SingleEmailMessage[]{message});
How to pass recordId here so Emailtemplate can take it and show further details (Name,Company).


Template is look alike is--
** NEW LEAD STATUS CHANGE NOTIFICATION ***

The following lead's status has been changed.

Lead Name: {!Lead.Name}

Company: {!Lead.Company}

Here is the Lead Detail: {!Lead.Link}

 
I'm not able to see Billing Statement object in Financial Service Cloud.

Is there any something which i have to enable in the org ??
Hi All,

I am facing issue for setting Boat images in style tag in BoatTile Component.

Here is BoatTile component and respective CSS.
BoatTile.cmp

<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
	
    <aura:attribute name="boat" type="Boat__c" default="{
                                                        'sObjectType' : 'Boat__c',
                                                        'Name' : '',
                                                        'Picture__c' : '',
                                                        'Contact__c' : ''
                                                        }"/>
    
    <aura:registerEvent name="selectedBoat" type="c:BoatSelect" />
    
    <lightning:button class="tile" >
    	<div style="{!'background-image:url(\'' + v.boat.Picture__c + '\'); '}" class="innerTile">
        	<div class="lower-third">
            	<h1 class="slds-truncate">{!v.boat.Contact__r.LastName}</h1>
            </div>
        </div>
    </lightning:button>
</aura:component>


BoatTile.css

.THIS.tile {
    position:relative;
    display: inline-block;
    width: 100%;
    height: 220px;
    padding: 1px !important;
}
.THIS .innertile {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
}
.THIS .lower-third {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    color: #FFFFFF;
    background-color: rgba(0, 0, 0, .4);
    padding: 6px 8px;
}



any suggestion on setting background-image ??

Regards
Sandeep
Hello All,

td which I want to reRender is aTotal field that is calculating based on remainings column values.
I have also put that td part in a <apex:ouputPanel>  rerender that panel, but it didn't work.

Any help would be appreciated

Regards
Sandeep
Hello everyone,
Is API integration is required to get any company's tweets in a sObject ??
For example i want to store google tweets in a object.

Any help regarding this ??

Regards
Sandeep
Here is what i have done.
By clicking on edit button am calling editActionHelper from JS Controller....
editActionHelper : function(component,event,helper){
        var buttonValue = event.getSource().get('v.value');
        var editRecordEvnt = $A.get('e.force:editRecord');
        editRecordEvnt.setParams({
            recordId : buttonValue
        });
        editRecordEvnt.fire();
        $A.get('e.force:refreshView').fire();
    },
Any help regarding this???
 
Hi All,

I have use a SVG icon for a button that is displaying in Chrome and Firefox but not displaying in IE 11.
I use this code as given in SLDS library.
<button class="slds-button slds-button_icon" title="Add New Competition" name="data" type="button" onclick="addCompetitionAF()">
    <svg class="slds-button__icon" aria-hidden="true">
        <use xlink:href="{!URLFOR($Asset.SLDS, '/assets/icons/utility-sprite/svg/symbols.svg#add')}"></use>
    </svg>
    <span class="slds-assistive-text">Add New Competition</span>
</button>
Please,suggest any correction what i need to add diffrent script to shown these images as a button in IE11.
Regards
Sandeep
 
Hi everyone,
I am calling this method from test class and it is not covering the statements inside if condition.
what's going wrong!!
Any help would be appreciate.User-added image
Hi everyone,
Here is my code--
when I debug it shows null value.
Any suggestion ??
<apex:page controller="AlertConId" >
  
  <script type="text/javascript">
      
      function demo(fst,lst)
      {
          var fn = document.getElementById(fst).value;
          var ln = document.getElementById(lst).value;
          myFunction(fn,ln);
      }
  </script>
  
  <apex:form >
      <apex:actionFunction name="myFunction" action="{!save}">
          <apex:param value="" name="fname" assignTo="{!fname}"/>
          <apex:param value="" name="lname" assignTo="{!lname}"/>
      </apex:actionFunction>
      
      <apex:pageBlock id="ref">
          <apex:pageBlockSection >
              <apex:inputText id="fname" label="FirstName"/>
              <apex:inputText id="lname" label="LastName"/>
              
              <apex:commandButton value="Go" onclick="demo('{!$Component.fname}','{!$Component.lname}')" reRender="ref"/>
          </apex:pageBlockSection>
      </apex:pageBlock>
  </apex:form>
</apex:page>

------------------------------------------------------------------------------------------------------------

public class AlertConId 
{
    public Contact ct {get;set;}
    public string fname {get;set;}
    public string lname {get;set;}
    
    public void save()
    {
        string first = ApexPages.currentPage().getParameters().get('fname');
        string last = ApexPages.currentPage().getParameters().get('lname');
        system.debug(first + last);
        
        ct = new Contact();
        ct.firstname = first;
        ct.lastname = last;
        try{
            insert ct;
        }
         catch(Exception e){}
    }
}

 
Hello everyone,
I want to upload a number of files when I select a value in the picklist.i.e. when I select 2 in picklist then it uploads only two files and so on.
Here is the code what I did to achieve this.
Thanks in advance
VF Page--

<apex:page standardController="Document" extensions="MyDocuments">
  <apex:form >
      <apex:pageBlock >          
          <apex:selectList value="{!len}" size="1">
              <apex:selectOptions value="{!option}"/>
              <apex:actionSupport event="onchange" action="{!uploadMultiFile}" reRender="lab"/>
          </apex:selectList>
      </apex:pageBlock>
      
      <apex:pageBlock title="UpLoad A File">
          <apex:pageBlockSection id="lab">
              <apex:repeat value="{!total}" var="t">
                  <apex:inputFile value="{!doc.body}" fileName="{!doc.name}"/>
              </apex:repeat>
              <apex:commandButton value="Save" action="{!save}"/>

          </apex:pageBlockSection>
      </apex:pageBlock>
  </apex:form>
</apex:page>

---------------------------------------------------------------------------------------------------------------------
Controller--

public class MyDocuments {
    
    public document doc {get;set;}
    public List<selectOption> option {get;set;}
    public String len {get;set;}
    public Integer total {get;set;}
    
    
    public MyDocuments(ApexPages.StandardController controller) 
    {
        doc = (Document)controller.getRecord();
        doc.folderId = UserInfo.getUserId();
        
        option = new List<selectOption>();
        option.add(new selectOption('','--None--'));
        for(Integer i=1; i<=10; i++)
        {
            option.add(new selectOption('val'+i,string.valueOf(i)));
        }
        
    }
    
    public void uploadMultiFile()
    {
        if(len == 'val1')
        {
            total = 1;
        }
        if(len == 'val2')
        {
            total = 2;
        }
    }

}

 
Am, using the concept of Wrapper class. I want to delete recently created contact record from pageBlockTable.
I am facing Unknown property 'SingleRecordDelete.ContactWrp.id' Error
Here is What I did--

VF page

<apex:page controller="SingleRecordDelete">
  <apex:form >
     <apex:pageBlock title="Contacts">
          <apex:pageBlockSection title="New Contact" columns="2" id="fresh">
              <apex:inputText label="FirstName" value="{!fname}" />
              <apex:inputText label="LastName" value="{!lname}"/>
              <apex:commandButton action="{!save}" value="Save" reRender="lab,fresh"/>
          </apex:pageBlockSection> 
         
          <apex:pageBlockSection title="ContactList" id="lab">
              <apex:pageBlockTable value="{!crp}" var="cy" id="update">
                  <apex:column headerValue="FirstName">
                      <apex:outputLabel value="{!cy.cn.firstname}"/>
                  </apex:column>
                  <apex:column headerValue="LastName">
                      <apex:outputLabel value="{!cy.cn.lastname}"/>
                  </apex:column>
                  <apex:column >
                         <apex:commandLink value="Delete" action="{!doDelete}" style="color:Red" reRender="lab">
                             <apex:param name="did" value="{!cy.id}" assignTo="{!did}"/>
                         </apex:commandLink>
                  </apex:column>
                  
              </apex:pageBlockTable>
                  
          </apex:pageBlockSection> 
               
     </apex:pageBlock>
  </apex:form>
</apex:page>

ApexClass
public with sharing class SingleRecordDelete {

    public String fname {get;set;}
    public String lname {get;set;}
    public String did {get;set;}
    
    public List<ContactWrp> crp {get;set;}
    
    public SingleRecordDelete(){
        crp = new List<ContactWrp>();
        
    }
    
    public void save(){
      Contact c = new Contact();
      c.firstname = fname;
      c.lastname = lname;
      insert c;
      crp.add(new ContactWrp(c));
      fname='';
      lname='';
    }
    
    public void doDelete()
    {
        List<Contact> contactToBeDelete = new List<Contact>();
        Contact cod = [select id from Contact where id =: did];
        contactToBeDelete.add(cod);
        delete contactToBeDelete;
    }
    
     public class ContactWrp{
    
      public Contact cn {get;set;}
      
        public ContactWrp(Contact cs){
            this.cn = cs;                   
        }
    }
}
On execution this in my Anonymous window --

List<List<sObject>> searchList = [FINd 'Mission Control' in ALL Field
                                   RETURNING Contact(FirstName,LastName,Email,Phone,Department)];

 Contact[] searchContacts = (Contact[])searchList[0];
    System.debug(searchContacts[0].LastName + ' ,' + searchContacts[0].FirstName);

a PopBox says that-
Unexpected Token at Line 1

 
Why I am getting this error--
"Executing the 'insertNewAccount' method failed. Either the method does not exist, is not static, or does not insert the proper account."
my code--

public class AccountHandler {

     public static Account insertNewAccount(String name){
        
          Account a = new Account();
          a.Name = 'name';
        
        try{
            insert a;
        }
        catch(Exception e){
            return null;
        }    
       return a;
    }
}
Hey Everyone,

Getting this error on lead conversion:

Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Status]: [Status]

I have also checked that LeadStatus is also set as Qualified.

Please help me there.
Here is what i have done...
Messaging.SendEmailResult[] results;
Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
message.setToAddresses(new String[] {ldOwnerMail});
message.setTemplateId([select id from EmailTemplate where DeveloperName='LeadsNewassignmentnotificationSAMPLE'].id);
message.setTargetObjectId(lead.OwnerId);

message.setSaveAsActivity(false);
results = Messaging.sendEmail(new Messaging.SingleEmailMessage[]{message});
How to pass recordId here so Emailtemplate can take it and show further details (Name,Company).


Template is look alike is--
** NEW LEAD STATUS CHANGE NOTIFICATION ***

The following lead's status has been changed.

Lead Name: {!Lead.Name}

Company: {!Lead.Company}

Here is the Lead Detail: {!Lead.Link}

 
I'm not able to see Billing Statement object in Financial Service Cloud.

Is there any something which i have to enable in the org ??
Here is what i have done.
By clicking on edit button am calling editActionHelper from JS Controller....
editActionHelper : function(component,event,helper){
        var buttonValue = event.getSource().get('v.value');
        var editRecordEvnt = $A.get('e.force:editRecord');
        editRecordEvnt.setParams({
            recordId : buttonValue
        });
        editRecordEvnt.fire();
        $A.get('e.force:refreshView').fire();
    },
Any help regarding this???
 
Hi All,

I have use a SVG icon for a button that is displaying in Chrome and Firefox but not displaying in IE 11.
I use this code as given in SLDS library.
<button class="slds-button slds-button_icon" title="Add New Competition" name="data" type="button" onclick="addCompetitionAF()">
    <svg class="slds-button__icon" aria-hidden="true">
        <use xlink:href="{!URLFOR($Asset.SLDS, '/assets/icons/utility-sprite/svg/symbols.svg#add')}"></use>
    </svg>
    <span class="slds-assistive-text">Add New Competition</span>
</button>
Please,suggest any correction what i need to add diffrent script to shown these images as a button in IE11.
Regards
Sandeep
 
i want to know how many times the execute method will run , so it is poossible to know using finish method.i mean after execute the batch class ,finnally i want see how many times my execute method will run. please give me simple example
Hi Team,

How can we write the test class for below class.
public with sharing class ControllerCls {
      
    public Contact co{get;set;}
    
    private final Contact con;
    
    private ApexPages.StandardController sc{get;set;}
    
    public Opportunity opp = new Opportunity();
    
    public ControllerCls(ApexPages.StandardController sc){
        this.sc = sc;
        con = (Contact)sc.getRecord();
        
        if(con.Name__c != Null){
            opp =[select id,name,AccountId from Opportunity where id =: con.Name__c limit 1];
        }
            
        co = new Contact();
        
        co.AccountId = opp.AccountId;
      
    }
    
    public PageReference save(){
        try{
            Database.insert(con);
            PageReference pr = new PageReference('/'+con.Id);
       		pr.setRedirect(true);
            return pr;
        }catch(Exception ex){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, ex.getMessage()));
            return null;
        }        
    }
    
    public PageReference saveNew()
     { 
         PageReference pr; 
         try{
             Database.insert(con);
         Schema.DescribeSObjectResult describeResult = sc.getRecord().getSObjectType().getDescribe();
         pr = new PageReference('/' + describeResult.getKeyPrefix() + '/e');
         pr.setRedirect(true);
         return pr;
         }catch(Exception e){ 
         ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, e.getMessage()));
         return null; }
     
     }
    
}
Please let me know how can we cover 100% code coverage.

Thanks,
sfdc dev.
 
  • September 18, 2018
  • Like
  • 0
    Hi All,
    my helper class is given below-
 //Helper class for Trigger_SocialPost
public without sharing class SocialPostTriggerHelper {
    public static List<SocialPost> newList;
    public static List<SocialPost> oldList;
    public static Map<Id, SocialPost> newMap;
    public static Map<Id, SocialPost> oldMap;
    
    public static Boolean runTrigger = true;
    
    public static void parseImageResponse(){
        Set<Id> socialPostIds = new Set<Id>(newMap.keySet());
        List<contentdocumentlink> cdlList = new List<contentdocumentlink>([Select id, 
                                                                              LinkedEntityId 
                                                                              from contentdocumentlink 
                                                                              where LinkedEntityId IN: socialPostIds]);
        List<Predictions__c> pdcList = new List<Predictions__c>();
        for(contentdocumentlink cdl : cdlList){
            if(newMap.containsKey(cdl.LinkedEntityId)){
               String jsonResponse = EinsteenPredictionService.getImagePrediction('test');
               EinsteenPredictionService ep= EinsteenPredictionService.parseImagePrediction(jsonResponse);
                for(EinsteenPredictionService.cls_probabilities result: ep.probabilities) {
                    Predictions__c    pc = new Predictions__c();
                    pc.Label__c = result.label;
                    pc.Probability__c = result.probability;
                    pc.ReferencetoSocialPost__c = cdl.LinkedEntityId;
                    pdcList.add(pc);
                }
               
            }
        }
        if(pdcList.size() > 0){
           insert pdcList; 
        }
        
    }
}
my test class is given below:-
@isTest
public class SocialPostTriggerHelperTest {
     @isTest static void SocialPostTriggerHelperTestmethod(){
        SocialPostTriggerHelper sth = new SocialPostTriggerHelper();
        SocialPostTriggerHelper.parseImageResponse();
        SocialPost sp = new SocialPost();
         
         Map<Id, SocialPost> newMap = new Map <Id, SocialPost>();
         newMap.put(sp.id,sp);
         insert sp;
         EinsteenPredictionService.cls_probabilities ein = new EinsteenPredictionService.cls_probabilities();
         ein.label = 'nachos';
         ein.probability = 0.9994034;
         
         contentdocumentlink cdl = new contentdocumentlink();
         
                    Predictions__c pc = new Predictions__c();
                    pc.Label__c = ein.label;
                    pc.Probability__c = ein.probability;
                    pc.ReferencetoSocialPost__c = cdl.LinkedEntityId;
         test.startTest();
         insert pc;
         test.stopTest();
     }
}
its showing this error:-System.NullPointerException: Attempt to de-reference a null object
                        Class.SocialPostTriggerHelper.parseImageResponse: line 11, column 1
                        Class.SocialPostTriggerHelperTest.SocialPostTriggerHelperTestmethod: line 5, column
     how to solve this error and cover the code?
Any suggestion?
  • September 17, 2018
  • Like
  • 0
Hello,

How can i calculate time between last modified date and present modified date and get the time in minutes.
where can i store t, in number field or text field.

thank for suggestion
  • September 17, 2018
  • Like
  • 0
Hi,

I am new in lightning. I am making one module in lightning, which have 4 or 5 buttons to do different activities. Should I create different component for each button or developments in the same (Base) component.


Thanks & Regards,
Kanahaiya
Hi everyone,
I am calling this method from test class and it is not covering the statements inside if condition.
what's going wrong!!
Any help would be appreciate.User-added image
Hi devs!
I'm having a problem when assigning a value into a custom field in a custom object. The error message is the following:
Line: 6, Column: 1
System.DmlException: Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST
Some important points:
  • I need it to be restricted.
  • This field doesn't use a global value set.
  • There's no record types defined for this object.
  • The value I'm trying to set are in the value set, and I already checked for typos.
  • If I unmark the "Restrick picklist to values..." option, the record saves, but an identical value is added to the picklist. 
  • I use the API value for the assignation, but I've tried with Label too.
  • The user can set the value trhough User Interface correctly
What could be happening here? 
Regards,
Mario Bravo
i want to create description custom fields on account and contact object
now i want to create a trigger on account object such that when i insert a record on account object contact shoul also be created with with the custom field updated same as account
please help me to achieve this