• Jitendra Singh Shahi
  • NEWBIE
  • 140 Points
  • Member since 2016


  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 31
    Replies
Hi Friends,

I have a requirement where I need to create a Quote when a Opportunity Product is added.
When creating a Quote I need to copy contact details based on Opportunity Contact Role where Contact is Primary.
I am getting Contact Name but, got Stuck in getting a Contact Email, Contact MailingAddress and Contact Other Address. It is not getting populated in Quote.
 
/** Trigger on Opportunity Line Item to insert Quote and Quotelineitem **/
trigger quoteCreation on OpportunityLineItem (after insert) {
    if(Trigger.isAfter && Trigger.isInsert){
        List<Quote> quoteList = new List<Quote>();
        Set<ID> oppIds = new Set<ID>();
        Set<Id> processIds = new Set<ID>();
        
        for(OpportunityLineItem oppli : Trigger.New){
            oppIds.add(oppli.Id);
        }
        
        List<OpportunityLineItem> opplList = new List<OpportunityLineItem>();
        if(oppIds != null && oppIds.size() >0){
            opplList = [SELECT Id, Opportunity.Name, Opportunity.AccountId, Opportunity.Account.PersonContactId, OpportunityId, Opportunity.Account.Name, Opportunity.Account.PersonEmail,
                        Opportunity.Account.Salutation, Opportunity.Account.BillingCity, Opportunity.Account.BillingCountry, Opportunity.Account.BillingPostalCode, Opportunity.Account.BillingState,
                        Opportunity.Account.ShippingCity, Opportunity.Account.ShippingCountry, Opportunity.Account.ShippingPostalCode, Opportunity.Account.ShippingState,
                        Opportunity.Account.BillingStreet, Opportunity.Account.ShippingStreet, Opportunity.ContactId, Opportunity.Account.isPersonAccount
                        FROM OpportunityLineItem 
                        WHERE Id IN:oppIds];
        }
        if(opplList != null && opplList.size() >0 ){
            for(OpportunityLineItem oppli : opplList) {        
                Quote quo = new Quote();
                quo.Name = 'Quote - ' + oppli.Opportunity.Name;
                quo.Status = 'Draft';
                quo.OpportunityId = oppli.OpportunityId;
               // Getting Contact Details from Business Account.
                if(oppli.Opportunity.Account.isPersonAccount == False)
                {
                    quo.ContactId = oppli.Opportunity.ContactId;
                    quo.Email = oppli.Opportunity.Contact.Email;
                    /*
                          Need to get Contact Mailing Address and Other Address.
                    */
                }

               // Getting Contact Details from Person Account.
                else
                {
                    quo.ContactId = oppli.Opportunity.Account.PersonContactId;
                    quo.Email = oppli.Opportunity.Account.PersonEmail;
                    quo.BillingName = oppli.Opportunity.Account.Name;
                    quo.ShippingName = oppli.Opportunity.Account.Name;
                    quo.BillingStreet = oppli.Opportunity.Account.BillingStreet; 
                    quo.BillingCity = oppli.Opportunity.Account.BillingCity;
                    quo.BillingCountry = oppli.Opportunity.Account.BillingCountry;
                    quo.BillingPostalCode = oppli.Opportunity.Account.BillingPostalCode;
                    quo.BillingState = oppli.Opportunity.Account.BillingState;
                    quo.ShippingStreet = oppli.Opportunity.Account.ShippingStreet;        
                    quo.ShippingCity = oppli.Opportunity.Account.ShippingCity;
                    quo.ShippingCountry = oppli.Opportunity.Account.ShippingCountry;
                    quo.ShippingPostalCode = oppli.Opportunity.Account.ShippingPostalCode;
                    quo.ShippingState = oppli.Opportunity.Account.ShippingState;
                }
               
                if(!processIds.contains(quo.OpportunityId))
                {
                    quoteList.add(quo);
                    processIds.add(quo.OpportunityID);
                }
            }
        }
        
        try {        
            if(quoteList.size() > 0) {    
                insert quoteList;
            }
        }
        catch(Exception e) {
            System.debug('The Following Exception has occurred: '+ e.getLinenumber() + ' : ' + e.getMessage());
        }
        // Insert Quote Line Item 
        set<Id> oppId = new Set<Id>();
        set<Id> pcrId = new set<Id>(); 
        List<QuoteLineItem> oliPist = new  List<QuoteLineItem>();
        if(quoteList != null && quoteList.size() >0){
            for(Quote quo : quoteList) {
                if(quo.opportunityId != null) {
                    oppId.add(quo.opportunityId);
                }
            }
        }
        Map<Id, List<OpportunityLineItem>> olitoOpp = new  Map<Id, List<OpportunityLineItem>>();
        if(oppId != null && oppId.size() >0){
            for(OpportunityLineItem oli : [SELECT Id, Quantity, UnitPrice, PricebookEntryId, Product2Id, OpportunityId 
                                           FROM OpportunityLineItem WHERE opportunityId IN : oppId]) {
                                               pcrId.add(oli.Product2Id);
                                               if(olitoOpp.containsKey(oli.opportunityId)) {
                                                   olitoOpp.get(oli.opportunityId).add(oli);
                                               }
                                               else {
                                                   olitoOpp.put(oli.opportunityId, new List<OpportunityLineItem> {oli});
                                               }
                                           }
        }
        
        for(Quote quot : quoteList) {
            if(olitoOpp.containsKey(quot.opportunityId)) {
                for(OpportunityLineItem  oli : olitoOpp.get(quot.opportunityId)){
                    if(oli != null)
                        oliPist.add(new QuoteLineItem(QuoteId=quot.Id,Quantity = oli.Quantity,PricebookEntryId = oli.PricebookEntryId,UnitPrice = oli.UnitPrice,Product2Id = oli.Product2Id));
                }
            }
        }
        if(!oliPist.isEmpty()) {
            insert oliPist;
        }
    }
}

Kindly review my code and let me know how can I get contact values.

Thanks in Advance.

 
Hello - Hoping to get help with this query. When a lead is created and if it has either a Core number or a PC Account Id number, I look for an account with that matching core number or pc Id. 

The problem with this query is, if a lead had a core number but no pc id, the query returns a non matching account because it returns any account that has no pc id. 

Do I need 2 different queries? One that looks for Core Number and another that looks for PC ID?

acctList = [SELECT Id, Core_Number__c, PC_Account_Id__c FROM Account WHERE Core_Number__c = :coreNumberTextList 
                            OR PC_Account_Id__c = :pcAccountIdList LIMIT 1];

Hi
How to Fetch only '"Contract Release' in below JSON Data :::

data->
        [{"Date_Reviewed":"1989-05-06","Date_Sent":"1989-05-05","editable":true,"Form":"Contract Revision 1","Id":"a0S3F000001bXAIUA2"},
        {"Date_Reviewed":"2019-02-01","Date_Sent":"2019-02-01","editable":true,"Form":"Contract Revision 2","Id":"a0S3F000001bXAJUA2"},
        {"Date_Reviewed":"2020-12-27","editable":true,"Form":"Contract Revision 3","Id":"a0S3F000001bXAKUA2"},
        {"Date_Reviewed":"2020-01-03","Date_Sent":"2020-01-03","editable":true,"Form":"Contract Release","Id":"a0S3F000001bXALUA2"},
        {"Date_Reviewed":"2020-12-29","editable":true,"Form":"Contract Revision 4","Id":"a0S3F000001bXAMUA2"},
        {"Date_Reviewed":"2020-12-30","editable":true,"Form":"Contract Revision 5","Id":"a0S3F000001bXANUA2"},
]        

My code :
saveDataTable :function(component, event) {
var data = component.get("v.data"); 
 var editedRecords1 =  component.find("riderStatusDataTable").get("v.draftValues");
for (var x in data)
            {
              var d = data[x];
 if(d.Form == "Contract Release" ){
  TemporaryArray1.Date_Sent__c = editedRecords1[0].Date_Sent;
           TemporaryArray1.Date_Reviewed__c = editedRecords1[0].Date_Reviewed;
break;
}
But , this is not Restrict for Contract Release ........its applied for all the Forms . I need this is for only 'Contract Release'...
can anyone help me...
Thanks
VRK
  • June 26, 2020
  • Like
  • 0
I am trying to create a loop that creates pallet locations and puts that information into a record. 

The first loop goes through the Section which is 1 to 46
The nested loop goes through the Aisle which is A to Q

I expect to start with the first section and then complete all the aisle before going back to iterating the through the Section again 

So when the loop starts I expected it to start the section at 1 and loop through the Aisle like so:
A1A
B1A
C1A
etc
then once it hits q it loops out, increases the section by 1 and does the nested loop again
A2A
B2A
C2A 
Can I get feedback on my code? 
List<Stock_Location__c > slnewt = new List <Stock_Location__c>();
StringBuilder sb = new StringBuilder();

for (Integer i = 1; j = 0; i < 46; i++) {

    for(char alphabet = 'a'; alphabet <= 'q'; alphabet++) {
    Stock_Location__c slnewt = new Stock_Location__c(
    Aisle__c = sb.append(alphabet),
    Section__c = i ,
    Shelf__c = 'a',
    barcode__c = sb.append(alphabet) + i + 'a',
    Location_Name__c =   sb.append(alphabet) + '-'  i+ '-'+ 'a'   
    );
    }

    slnewt.add(slnew);
}

Insert slnewt;

 
Hello - I need help adding Account Ids to Contacts. I tried using a map but I don't have any matching keySet that will return the Id. Can I add the Ids to a list and then assign the Id from the list to a updateCt.AccountId?  If so, how can I do this without writing a different class?
 
//Query newly created Account
       List <Account> insertedAcct = [SELECT Id FROM Account WHERE Id =:insertAccounts];

//Query contact that needs the new Account Id 
        List <Contact> indClientIdList = [SELECT Id, AccountId FROM Contact WHERE Id = :clientIdList];
        
        if(indClientIdList.size() > 0){
            for(Contact updateCT : indClientIdList){
                updateCt.AccountId =   NEW ACCOUNT Id HERE );
            }
        }



 
Hello,

I am looking to do the following:
When a new case is created with a custom field (Unique ID) populated i want SFDC to find the matching unique ID in an account record and then autopopulate the Account name on the case object.

I appreciate any help i can get!

Thank you,
Leonie
Hi Friends,

I have a requirement where I need to create a Quote when a Opportunity Product is added.
When creating a Quote I need to copy contact details based on Opportunity Contact Role where Contact is Primary.
I am getting Contact Name but, got Stuck in getting a Contact Email, Contact MailingAddress and Contact Other Address. It is not getting populated in Quote.
 
/** Trigger on Opportunity Line Item to insert Quote and Quotelineitem **/
trigger quoteCreation on OpportunityLineItem (after insert) {
    if(Trigger.isAfter && Trigger.isInsert){
        List<Quote> quoteList = new List<Quote>();
        Set<ID> oppIds = new Set<ID>();
        Set<Id> processIds = new Set<ID>();
        
        for(OpportunityLineItem oppli : Trigger.New){
            oppIds.add(oppli.Id);
        }
        
        List<OpportunityLineItem> opplList = new List<OpportunityLineItem>();
        if(oppIds != null && oppIds.size() >0){
            opplList = [SELECT Id, Opportunity.Name, Opportunity.AccountId, Opportunity.Account.PersonContactId, OpportunityId, Opportunity.Account.Name, Opportunity.Account.PersonEmail,
                        Opportunity.Account.Salutation, Opportunity.Account.BillingCity, Opportunity.Account.BillingCountry, Opportunity.Account.BillingPostalCode, Opportunity.Account.BillingState,
                        Opportunity.Account.ShippingCity, Opportunity.Account.ShippingCountry, Opportunity.Account.ShippingPostalCode, Opportunity.Account.ShippingState,
                        Opportunity.Account.BillingStreet, Opportunity.Account.ShippingStreet, Opportunity.ContactId, Opportunity.Account.isPersonAccount
                        FROM OpportunityLineItem 
                        WHERE Id IN:oppIds];
        }
        if(opplList != null && opplList.size() >0 ){
            for(OpportunityLineItem oppli : opplList) {        
                Quote quo = new Quote();
                quo.Name = 'Quote - ' + oppli.Opportunity.Name;
                quo.Status = 'Draft';
                quo.OpportunityId = oppli.OpportunityId;
               // Getting Contact Details from Business Account.
                if(oppli.Opportunity.Account.isPersonAccount == False)
                {
                    quo.ContactId = oppli.Opportunity.ContactId;
                    quo.Email = oppli.Opportunity.Contact.Email;
                    /*
                          Need to get Contact Mailing Address and Other Address.
                    */
                }

               // Getting Contact Details from Person Account.
                else
                {
                    quo.ContactId = oppli.Opportunity.Account.PersonContactId;
                    quo.Email = oppli.Opportunity.Account.PersonEmail;
                    quo.BillingName = oppli.Opportunity.Account.Name;
                    quo.ShippingName = oppli.Opportunity.Account.Name;
                    quo.BillingStreet = oppli.Opportunity.Account.BillingStreet; 
                    quo.BillingCity = oppli.Opportunity.Account.BillingCity;
                    quo.BillingCountry = oppli.Opportunity.Account.BillingCountry;
                    quo.BillingPostalCode = oppli.Opportunity.Account.BillingPostalCode;
                    quo.BillingState = oppli.Opportunity.Account.BillingState;
                    quo.ShippingStreet = oppli.Opportunity.Account.ShippingStreet;        
                    quo.ShippingCity = oppli.Opportunity.Account.ShippingCity;
                    quo.ShippingCountry = oppli.Opportunity.Account.ShippingCountry;
                    quo.ShippingPostalCode = oppli.Opportunity.Account.ShippingPostalCode;
                    quo.ShippingState = oppli.Opportunity.Account.ShippingState;
                }
               
                if(!processIds.contains(quo.OpportunityId))
                {
                    quoteList.add(quo);
                    processIds.add(quo.OpportunityID);
                }
            }
        }
        
        try {        
            if(quoteList.size() > 0) {    
                insert quoteList;
            }
        }
        catch(Exception e) {
            System.debug('The Following Exception has occurred: '+ e.getLinenumber() + ' : ' + e.getMessage());
        }
        // Insert Quote Line Item 
        set<Id> oppId = new Set<Id>();
        set<Id> pcrId = new set<Id>(); 
        List<QuoteLineItem> oliPist = new  List<QuoteLineItem>();
        if(quoteList != null && quoteList.size() >0){
            for(Quote quo : quoteList) {
                if(quo.opportunityId != null) {
                    oppId.add(quo.opportunityId);
                }
            }
        }
        Map<Id, List<OpportunityLineItem>> olitoOpp = new  Map<Id, List<OpportunityLineItem>>();
        if(oppId != null && oppId.size() >0){
            for(OpportunityLineItem oli : [SELECT Id, Quantity, UnitPrice, PricebookEntryId, Product2Id, OpportunityId 
                                           FROM OpportunityLineItem WHERE opportunityId IN : oppId]) {
                                               pcrId.add(oli.Product2Id);
                                               if(olitoOpp.containsKey(oli.opportunityId)) {
                                                   olitoOpp.get(oli.opportunityId).add(oli);
                                               }
                                               else {
                                                   olitoOpp.put(oli.opportunityId, new List<OpportunityLineItem> {oli});
                                               }
                                           }
        }
        
        for(Quote quot : quoteList) {
            if(olitoOpp.containsKey(quot.opportunityId)) {
                for(OpportunityLineItem  oli : olitoOpp.get(quot.opportunityId)){
                    if(oli != null)
                        oliPist.add(new QuoteLineItem(QuoteId=quot.Id,Quantity = oli.Quantity,PricebookEntryId = oli.PricebookEntryId,UnitPrice = oli.UnitPrice,Product2Id = oli.Product2Id));
                }
            }
        }
        if(!oliPist.isEmpty()) {
            insert oliPist;
        }
    }
}

Kindly review my code and let me know how can I get contact values.

Thanks in Advance.

 
Hi there, 
I have an object Campaign_Follow_Up_Stage__c, On this object, I have a Campaign Lookup.
On Campaign_Follow_Up_Stage__c object, there are some record which status is "completed", If the status of any of these records 
changes, supposed I changed the status of one record  "Completed" to "Planned" then Campaign status field changed 
the value "In-progress".
* If all records status is completed then-campaign status field value is Completed.
* If all records status is Planned then-campaign status field value is In-progress.
* If all records status is Draft then-campaign status field value is Planned.
* If one of it's record status is planned then-campaign status field value is In-progress.
* If one of it's record status is Draft then-campaign status field value is planned.


trigger updateCampaignStatus on Campaign_Follow_Up_Stage__c (after Update,after insert) {
//list<Campaign_Follow_Up_Stage__c> cList = new list<Campaign_Follow_Up_Stage__c>(); 
    set<Id> campIds = new set<Id>();   
        for(Campaign_Follow_Up_Stage__c c : trigger.new){  
          campIds.add(c.Campaign__c);  
        }     
   List<Campaign> cmList = new List<Campaign>();
    for(Campaign cam:[SELECT Id,(SELECT Id,Name,status__c ,Campaign__c FROM Campaign_Follow_Up_Stages__r order by Name) FROM Campaign WHERE Id IN :campIds]){
        for(Campaign_Follow_Up_Stage__c c:cam.Campaign_Follow_Up_Stages__r){
             if(c.status__c == 'Completed'){
                 cam.status ='Completed';
             }
             if(c.status__c =='Planned'){
                 cam.status ='In Progress';
             }
             if(c.status__c =='Draft'){
                 cam.status ='Planned';
             }
             cmList.add(cam);
        }
    }
     update cmList;
}


Any help appreciated

Thanks 
L.N
Hello - Hoping to get help with this query. When a lead is created and if it has either a Core number or a PC Account Id number, I look for an account with that matching core number or pc Id. 

The problem with this query is, if a lead had a core number but no pc id, the query returns a non matching account because it returns any account that has no pc id. 

Do I need 2 different queries? One that looks for Core Number and another that looks for PC ID?

acctList = [SELECT Id, Core_Number__c, PC_Account_Id__c FROM Account WHERE Core_Number__c = :coreNumberTextList 
                            OR PC_Account_Id__c = :pcAccountIdList LIMIT 1];
Hi, I keep trying to install the Salesforce Lightning Inspector Chrome extension but can never find the correct Chrome Web Store page. It's supposed to be here:

https://chrome.google.com/webstore/detail/salesforce-lightning-insp/pcpmcffcomlcjgpcheokdfcjipanjdpc , as per 

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/inspector_install.htm

but always get an HTTP 404 error.

Do you guys know where exactly the installation is? Thanks!!   OR... has it been deprecated?
HI All, 

I want to make phone required when i click the create lead button.
But the lead is creating without phone. And also i need to show when phone is empty show tost message.  

Below is my code and it is not working. 

HTML:
<div class="slds-col slds-size_2-of-7">
<lightning-input-field class="Phone" required field-name="Phone"
value={leadphone}>
</lightning-input-field>
</div>

Js.code
handleSubmit(event) {
        this.createlabel = "Creating Lead...";
        event.preventDefault();
        const fields = event.detail.fields;   // stop the form from submitting
        if (this.template.querySelector('.Phone') === '') {
            this.fieldvalidationerror();
        } else {
            this.template.querySelector('lightning-record-edit-form').submit(fields);
        }
    }

//Tost Message
fieldvalidationerror() {
const event = new ShowToastEvent({
mode: 'dismissable',
variant: 'error',
title: 'We hit a snag!',
message: 'Please fill required fields'
});
this.dispatchEvent(event);
}User-added image
 

Hi
How to Fetch only '"Contract Release' in below JSON Data :::

data->
        [{"Date_Reviewed":"1989-05-06","Date_Sent":"1989-05-05","editable":true,"Form":"Contract Revision 1","Id":"a0S3F000001bXAIUA2"},
        {"Date_Reviewed":"2019-02-01","Date_Sent":"2019-02-01","editable":true,"Form":"Contract Revision 2","Id":"a0S3F000001bXAJUA2"},
        {"Date_Reviewed":"2020-12-27","editable":true,"Form":"Contract Revision 3","Id":"a0S3F000001bXAKUA2"},
        {"Date_Reviewed":"2020-01-03","Date_Sent":"2020-01-03","editable":true,"Form":"Contract Release","Id":"a0S3F000001bXALUA2"},
        {"Date_Reviewed":"2020-12-29","editable":true,"Form":"Contract Revision 4","Id":"a0S3F000001bXAMUA2"},
        {"Date_Reviewed":"2020-12-30","editable":true,"Form":"Contract Revision 5","Id":"a0S3F000001bXANUA2"},
]        

My code :
saveDataTable :function(component, event) {
var data = component.get("v.data"); 
 var editedRecords1 =  component.find("riderStatusDataTable").get("v.draftValues");
for (var x in data)
            {
              var d = data[x];
 if(d.Form == "Contract Release" ){
  TemporaryArray1.Date_Sent__c = editedRecords1[0].Date_Sent;
           TemporaryArray1.Date_Reviewed__c = editedRecords1[0].Date_Reviewed;
break;
}
But , this is not Restrict for Contract Release ........its applied for all the Forms . I need this is for only 'Contract Release'...
can anyone help me...
Thanks
VRK
  • June 26, 2020
  • Like
  • 0
I would like to keep a link in the VF component and from that link I need to open Lightning component.
  • June 25, 2020
  • Like
  • 0