• house of outsourcing
  • NEWBIE
  • -2 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 8
    Replies
https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_jwt_flow.htm#sfdx_dev_auth_jwt_flow

Following the above steps, I am keeping on getting this error in running this command, any idea why? I am using free Developer edition online.
 
sfdx auth:jwt:grant --clientid mQ_ZAy3OwMRG2dGPyIt8KME3N --jwtkeyfile C:\Users\hujir\JWT\server.key --username jirong.hu@playful-bear-6bongz.com  --setdefaultdevhubusername --setalias my-hub-org
NOTE: There are _NO QUOTES_ of any kind in my CSV file (UTF-8 encoded).

Is this an encoding error? Why does the salesforce csvreader class think that there is an unescaped quote???
hi gyus... This code is working fine..when ever I insert or update record it sends email.. but I am quite confused  so plz explain me the use of line 16,line 19,line 25 & what is the use of flag... and tell me that is messaging.singleEmailMessage is defined keyword...??
Last but not the least I want to edit the code in such a way that if i insert the data with dataloader where there is more than one contact then send email to more than one contact is inserted at a time....

************apex class**********
public with sharing class HelperContactTrigger {
    public static List<Contact> sendEmail(List<Contact>Contacts)
    {
     //query on template object
        EmailTemplate et=[Select id from EmailTemplate where name=:'Sales: New Customer Email'];

        //list of emails
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();   
        
        for(Contact con : Contacts)
        {
          //check for Account
            if(con.AccountId != null && con.Email != null){

                //initiallize messaging method
                Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();

                //set object Id
                singleMail.setTargetObjectId(con.Id);

                //set template Id
                singleMail.setTemplateId(et.Id);

                //flag to false to stop inserting activity history
                singleMail.setSaveAsActivity(false);

                //add mail
                emails.add(singleMail);
            }
        }
            //send mail
        Messaging.sendEmail(emails);

        return Contacts;          
        
    }

    public static List<Contact> sendEmailafter(List<Contact>Contacts)
    {
    //query on template object
        EmailTemplate et=[Select id from EmailTemplate where name=:'Sales: New Customer Email'];

        //list of emails
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();   
        
        for(Contact con : Contacts)
        {
          //check for Account
            if(con.AccountId != null && con.Email != null){

                //initiallize messaging method
                Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();

                //set object Id
                singleMail.setTargetObjectId(con.Id);

                //set template Id
                singleMail.setTemplateId(et.Id);

                //flag to false to stop inserting activity history
                singleMail.setSaveAsActivity(false);

                //add mail
                emails.add(singleMail);
            }
         }
            //send mail
        Messaging.sendEmail(emails);

        return Contacts;          
        }
    }

*********Apex trigger********
trigger SendEmailToAccount on Contact (after insert,after update) 
{
    if(Trigger.isAfter)
    {
        if(Trigger.isInsert )
        { 
            //helper class for single email but bulk messages
            HelperContactTrigger.sendEmail(trigger.new);
        }
    }
        if(trigger.isAfter && trigger.isUpdate )
        {           
         HelperContactTrigger.sendEmailafter(trigger.new);
        }
}

 
Hello Friends,
I have this  below code.
<apex:page standardController="Account">
    {! Account.Name }
    {! Account.Phone}
</apex:page>
I can comment the code by standard way (" <!-- This is commented part --> ") which I can do with few clicks.

Is there a way using the keyboard shortcut to do so? MS Visual Studio has it. May be the Eclipse too, although not sure.

Please help, thanks!

I'm new to Apex and have been mulling over the best way to do this:

 

I have a lookup field to the product object on the lead object.  When entering a lead the user selects the product they are interested in.

 

When the lead is qualified and converted, I want to not only create an opportunity (straightforward Salesforce) but I want to match the value in the lookup field on the lead object to the product object and insert this as the product (opportunity line item?) associated with the opportunity. I also want to be able to recognize the pricebook that this product belongs and insert the price into the 'Sales price' field.

 

Should I use the lead object in this? Should I create the trigger on the opportunity object? Suggestions will be greatly appreciated.

 

I'm trying to start by adapting this code I found.

 

trigger addProductFromLead on Opportunity (after insert) {

 

//Build Product Ids to use in query
Set<ID> oppProdId = new Set<ID>();

//Build list of Opportunities to update the Price Book ID field
List<Opportunity> oppList = new List<Opportunity>();

//Set used to create Opportunity Products
List<OpportunityLineItem> oliList = new List<OpportunityLineItem>();

//Map used to match Products to PriceBookEntry records
Map<ID, ID> pbeMap = new Map<ID, ID>();


for(Opportunity o : Trigger.new) {

//Only use the Opportunity if it is created with a Product__c value (i.e. - On Convert) if(o.AnticipatedCourse__c != null) {

oppProdId.add(otemp.Product__c);
//Add the product id to the set
Opportunity otemp = o.clone();
//Create a duplicate Opportunity to use in an update
otemp.PriceBook2Id = '01sd0000000Q1YD'; // I'd like to be able to dynamically recognize the correct price book
//Set the Price Book of the Opportunity
oppList.add(otemp); //seems to be a problem with declaring this variable
}
}
//Update all of the Opportunities with the Price Book
update oppList;
for(PriceBookEntry pbe : [select Id, Product2Id from PriceBookEntry where PriceBook2Id =
'01sd0000000Q1YD' and Product2Id in :oppProdId]) {
//Build the map to use to match Procucts to PriceBookEntries
pbeMap.put(pbe.Product2Id, pbe.id);
}
for(Opportunity opp : oppList) {
//Build the OpportunityLineItems for each Opportunity (sets the quantity to 1 and the
price to 100)
OpportunityLineItem oli = new OpportunityLineItem(OpportunityId = opp.id,
PriceBookEntryId = pbeMap.get(opp.Product__c), Quantity = 1, UnitPrice = 100);
oliList.add(oli);
}
if(oliList.size() > 0) {
//Create the OpportunityLineItems
insert oliList;
}

}

Is there a way to get a list of Account records (parent) with no child records associated (Opportunity)  via SOQL?

I am trying to avoid doinf this in Apex, like getting the AccountId values from Opportunity and then query accounts where id not in this list.

 

Is it possible to get this list through SQOL?


Here is my query (I need only the accounts that have no associated Opportunity records):

 

SELECT a.Id, a.Name, (Select id from Opportunities) from Account a order by a.Name

 

Thanks,

Rodrigo

Can u please tell me the diff btn Iterable and Database.Querylocator() in Batch apex?

Just tell me few words.

 

Thanks