• Randall Toepfer
  • NEWBIE
  • 5 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
I'm getting an error on sfdx cli authorize an org.  I'm experiencing the error on two different Salesforce orgs on two, accessed by two different laptops (my corporate laptop and personal laptop used for freelancing), and on two different networks (my corporate VPN and home network).

The error is:

We can't authorize you because of an OAuth error. For more information, contact your Salesforce administrator.
OAUTH_APPROVAL_ERROR_GENERIC : An unexpected error has occured during authentication. Please try again.

I've tried setting "relaxing ip restrictions" on the Salesforce CLI app, and tried running the sfdx authorize command with the scope in the url:

sfdx force:auth:web:login -r https://login.salesforce.com/services/oauth2/authorize?prompt=login&scope=full

Nothing is working and the OAuth hangs until I hit refresh and then get the above error.  I've tried in Firefox and Chrome browsers and after deleting cache.

Anyone know of a solution?  Thanks
I have some PHP SOAP code that connects to Salesforce and creates a lead.  The code works for Sandbox but gives an error in production

"Fatal error: Uncaught SoapFault exception: [INVALID_LOGIN] INVALID_LOGIN: Invalid username, password, security token; or user locked out."

I've verififed my credentials, even reset my security token.  I noticed in the enterprise WSDL I am using that the location doesn't match my org id?  I tried changing the location to my org id but I still get this error.

<soap:address location="https://login.salesforce.com/services/Soap/c/45.0/ID"/>
Why would a "run all tests" pass in Sandbox but when deployed to production I get an error too many SOQL queries?
 
trigger ZD_Opportunity_BeforeInsert_BeforeUpdate on Opportunity (before insert, before update) {
        
    ZD_Opportunity_Utility.createCongaTemplate(Trigger.new, false);
}
 
public static String getCongaTemplateId(String sTemplateName)
    {
        if(sTemplateName == '')
            throw new ZD_Exception('Error getCongaTemplateId param');
                
        if(m_mTemplates == null)
            m_mTemplates = new Map<String, APXTConga4__Conga_Template__c>();
        
        // search Conga object for template name then get id
        String sResult = '';
        APXTConga4__Conga_Template__c oTemplate;
        
        if(m_mTemplates.containsKey(sTemplateName))
        {
            oTemplate = m_mTemplates.get(sTemplateName);
        
        	sResult = '' + oTemplate.Id; 
        }
        else
        {        
            List<APXTConga4__Conga_Template__c> lCongaTemplates = [
                SELECT
                    Id,
                    Name
                FROM
                    APXTConga4__Conga_Template__c
                WHERE
                    APXTConga4__Name__c = :sTemplateName
            ];        
            if(lCongaTemplates.size() == 0)
            {
                // throw new ZD_Exception('Error finding Conga Template ' + sTemplateName);
                sResult = 'xxx';
            }
            else
            {
                oTemplate = lCongaTemplates[0];
                
                m_mTemplates.put(oTemplate.Name, oTemplate);
                        
                sResult = '' + oTemplate.Id; 
            }
        }
        
        return sResult;
    }
    
    public static void createCongaTemplate(List<Opportunity> lOpportunities, Boolean bAfter) {
        Boolean bDataChange = false;
        
        for(Opportunity oOpportunity : lOpportunities)
        {           
            // get all opportunity products
            List<OpportunityLineItem> lLineItems = [
                SELECT 
                	Id, 
                	Product2.Id,
                	Product2.Name,
                	Product2.Family
                FROM 
                	OpportunityLineItem
                WHERE 
                	OpportunityId = :oOpportunity.Id
            ];
            
            // template string
            String sTemplateIds = '';
            String sScheduleA = '';
            String sContract = '';
            String sExhibitA = '';
            String sExhibitB = '';
            String sExhibitC = '';
            String sExhibitD = '';
            String sSpecSheets = '';
            
            // template order: schedule A, contract, exhitbit a - warranty, exhibit b - ppg, exhibit c - consumer protect plan, exhibit d - cancel notice
            
            // get opportunity record type
        	List<RecordType> lOpportunityRecordTypes =  [
                SELECT 
                	Id, 
                	Name, 
                	DeveloperName 
                FROM 
                	RecordType 
                WHERE 
                	Id = :oOpportunity.RecordTypeId
            ];     
            
            if(lOpportunityRecordTypes.size() == 0)
                throw new ZD_Exception('Error opportunity record type');
                        
            // Energy Efficiency
            if(lOpportunityRecordTypes[0].DeveloperName == 'Residential_EE')
            {
                // find schedule A template for EE       
                sScheduleA = ZD_Opportunity_Utility.getCongaTemplateId('EE Schedule A'); 
                
                // find contract template for EE
                sContract = ZD_Opportunity_Utility.getCongaTemplateId('EE Contract'); 
            }
            
            // default to PV Install
            else 
            {
                // find schedule A template for PV Install 
                sScheduleA = ZD_Opportunity_Utility.getCongaTemplateId('PV Install Schedule A');
                
                // find contract template for PV Install
                sContract = ZD_Opportunity_Utility.getCongaTemplateId('PV Install Contract'); 
                
                // setup warranties
                
                // keep track of warranties and spec sheets we have already added
                Set<String> sWarranties = new Set<String>();
                Set<String> sSpecs = new Set<String>();
                
                // loop through each line item and get warranty and spec sheets
                for(Integer ix = 0; ix < lLineItems.size(); ix++)
                {
                    Id oProductId = lLineItems[ix].Product2.Id;
                    
                    // get warranties
                    List<Warranty_Junction__c> lWarranties = [
                        SELECT 
                        	Conga_Template__c 
                        FROM 
                        	Warranty_Junction__c 
                        WHERE 
                        	Product__c = :oProductId
                    ];
                    
                    for(Integer jx = 0; jx < lWarranties.size(); jx++)
                    {
                        String sId = '' + lWarranties[jx].Conga_Template__c;
                        
                        // add each warranty to set
                        if(sWarranties.contains(sId))
                            continue;
                        
                        sWarranties.add(sId);
                    }
                    
                    // get spec sheets
                    List<Spec_Sheet_Junction__c> lSpecSheets = [
                        SELECT 
                        	Conga_Template__c 
                        FROM 
                        	Spec_Sheet_Junction__c 
                        WHERE 
                        	Product__c = :oProductId                        
                    ];
                    
                    for(Integer jx = 0; jx < lSpecSheets.size(); jx++)
                    {
                        String sId = '' + lSpecSheets[jx].Conga_Template__c;
                        
                        // add each warranty to set
                        if(sSpecs.contains(sId))
                            continue;
                        
                        sSpecs.add(sId);
                    }
                }
                
                // add each warranty id to template
                sExhibitA = ZD_Opportunity_Utility.getCongaTemplateId('PV Install Contract - Exhibit A');
                for(String sId : sWarranties)
                {
                    sExhibitA = sExhibitA + ',' + sId;
                }         
                
                // add PPG to template
                sExhibitB = 
                    ZD_Opportunity_Utility.getCongaTemplateId('PV Install Contract - Exhibit B') + ',' +
                    ZD_Opportunity_Utility.getCongaTemplateId('PV Install PPG'); 
                
                // add 25 year consumer protection plan
            	sExhibitC = 
                    ZD_Opportunity_Utility.getCongaTemplateId('PV Install Contract - Exhibit C') + ',' +                    
                    ZD_Opportunity_Utility.getCongaTemplateId('Warranty - SCS 25 Year'); 
                
                // add notice of cancellation
            	sExhibitD = ZD_Opportunity_Utility.getCongaTemplateId('PV Install Contract - Exhibit D');
                
                // add each spec sheet id to template
                for(String sId : sSpecs)
                {
                    if(sSpecSheets.length() == 0)
                    	sSpecSheets = sId;
                    else
                    	sSpecSheets = sSpecSheets + ',' + sId;
                }         
            }
                        
            sTemplateIds = 
                sScheduleA + ',' + 
                sContract + ',' + 
                sExhibitA + ',' +
                sExhibitB + ',' +
                sExhibitC + ',' +
                sExhibitD;
            
            if(sSpecSheets.length() > 0)
                sTemplateIds = sTemplateIds + ',' + sSpecSheets;
            
            String sExistingTemplate = oOpportunity.CongaTemplateIds__c;
            
            if(sExistingTemplate != sTemplateIds)
                bDataChange = true;
            
            // set template field
            oOpportunity.CongaTemplateIds__c = sTemplateIds;            
        }   
        
        if(bAfter && bDataChange)
            update lOpportunities;
    }

 
I'm getting an error on sfdx cli authorize an org.  I'm experiencing the error on two different Salesforce orgs on two, accessed by two different laptops (my corporate laptop and personal laptop used for freelancing), and on two different networks (my corporate VPN and home network).

The error is:

We can't authorize you because of an OAuth error. For more information, contact your Salesforce administrator.
OAUTH_APPROVAL_ERROR_GENERIC : An unexpected error has occured during authentication. Please try again.

I've tried setting "relaxing ip restrictions" on the Salesforce CLI app, and tried running the sfdx authorize command with the scope in the url:

sfdx force:auth:web:login -r https://login.salesforce.com/services/oauth2/authorize?prompt=login&scope=full

Nothing is working and the OAuth hangs until I hit refresh and then get the above error.  I've tried in Firefox and Chrome browsers and after deleting cache.

Anyone know of a solution?  Thanks
I'm getting an error on sfdx cli authorize an org.  I'm experiencing the error on two different Salesforce orgs on two, accessed by two different laptops (my corporate laptop and personal laptop used for freelancing), and on two different networks (my corporate VPN and home network).

The error is:

We can't authorize you because of an OAuth error. For more information, contact your Salesforce administrator.
OAUTH_APPROVAL_ERROR_GENERIC : An unexpected error has occured during authentication. Please try again.

I've tried setting "relaxing ip restrictions" on the Salesforce CLI app, and tried running the sfdx authorize command with the scope in the url:

sfdx force:auth:web:login -r https://login.salesforce.com/services/oauth2/authorize?prompt=login&scope=full

Nothing is working and the OAuth hangs until I hit refresh and then get the above error.  I've tried in Firefox and Chrome browsers and after deleting cache.

Anyone know of a solution?  Thanks
Hi experts,
I have the following challenge I'm struggling with. The requested functionality is when saving an email with attachment from (e.g.) Salesforce App for Outlook to Salesforce and attaching the email to the opportunity, the attachment itself (not only the email) should additionally be attached to the opportunity.
So far, I figured out that 
  • (of course) the email is saved as a task
  • the attachment is saved in the ContentDocument table
  • the link between the email and the attachment is saved in the ContentDocumentLink table (plus the permissions that are applied)
  • additionally the link between the attachment and the opportunity's account (in the task's WhatId) is also saved as an additional entry in the ContentDocumentLink table
What I wanted to achieve with a trigger on the task object is to create a thrid entry in the ContentDocumentLink table between the opportunity itself an the email attachment. (This entry is created when I manually post the file (from Salesforce) to the opportunity feed.)

The problem is - at least that's what I'm thinking - that the entry in the ContentDocumentLink table is created in a separate transaction on the DB. The (after insert) trigger on the task cannot find any entries in the ContentDocumentLink table. If I check via workbench the entry is there.

Here is the trigger (probably not the best code since I'm not a developer - apologies for that :-)):
 
trigger addEmailAttachToWhatId on Task (after insert) {

    ContentDocumentLink doclink= new ContentDocumentLink ();   
    ContentDocumentLink doclinkold= new ContentDocumentLink ();   
    List<Id> tskL = new List<Id>();
    List<ContentDocumentLink> doclinkL = new List<ContentDocumentLink>();
    List<ContentDocumentLink> doclinks = new List<ContentDocumentLink>();

    try{
        for(Task t : Trigger.new){
            tskL.add(t.Id); 
        }    

        doclinks= [SELECT ContentDocumentId, LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId in :tskL];
    }catch(Exception e){
    }
            
    for(Task task : Trigger.new){
        
        if(task.whatId != null){
                
            for (ContentDocumentLink dlink : doclinks){
                if (dlink.LinkedEntityId == task.Id){
                    doclink.ContentDocumentId= dlink.ContentDocumentId;
                    doclink.LinkedEntityId = task.WhatId;
                    doclink.ShareType = 'V';
                    doclink.Visibility = 'InternalUsers';
                    doclinkL.add(doclink);
                 }
            }
        }
    }       
    insert doclinkL;       
}

The message in the Debug log is as follows:
 
36.0 APEX_CODE,DEBUG;APEX_PROFILING,DEBUG;CALLOUT,INFO;DB,DEBUG;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,DEBUG;WORKFLOW,DEBUG
12:26:48.0 (585253)|EXECUTION_STARTED
12:26:48.0 (615652)|CODE_UNIT_STARTED|[EXTERNAL]|01q24000000TjWc|addEmailAttachToWhatId on Task trigger event AfterInsert for [00T2400000cMmED]
12:26:48.0 (15796812)|SOQL_EXECUTE_BEGIN|[28]|Aggregations:0|SELECT ContentDocumentId, LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId IN :tmpVar1
12:26:48.0 (43505087)|SOQL_EXECUTE_END|[28]|Rows:0
12:26:48.44 (44045805)|CUMULATIVE_LIMIT_USAGE
12:26:48.44 (44045805)|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 1 out of 100
  Number of query rows: 0 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Maximum CPU time: 0 out of 10000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 100
  Number of Email Invocations: 0 out of 10
  Number of future calls: 0 out of 50
  Number of queueable jobs added to the queue: 0 out of 50
  Number of Mobile Apex push calls: 0 out of 10

12:26:48.44 (44045805)|CUMULATIVE_LIMIT_USAGE_END

12:26:48.0 (45844070)|CODE_UNIT_FINISHED|addEmailAttachToWhatId on Task trigger event AfterInsert for [00T2400000cMmED]
12:26:48.0 (47962053)|EXECUTION_FINISHED
12:26:48.53 (53178488)|EXECUTION_STARTED
12:26:48.53 (53192920)|CODE_UNIT_STARTED|[EXTERNAL]|Workflow:Task
12:26:48.53 (68766665)|WF_RULE_EVAL_BEGIN|Workflow
12:26:48.53 (68822118)|WF_CRITERIA_BEGIN|[Aufgabe:  00T2400000cMmED]|Email in Subject Line|01Q24000000Upow|ON_CREATE_OR_TRIGGERING_UPDATE|0
12:26:48.53 (73895645)|WF_RULE_FILTER|[Aufgabe : Thema beginnt mit Email]
12:26:48.53 (73924226)|WF_RULE_EVAL_VALUE|E-Mail:Test Email mit Attachment
12:26:48.53 (73931095)|WF_CRITERIA_END|false
12:26:48.53 (73962473)|WF_SPOOL_ACTION_BEGIN|Workflow
12:26:48.53 (73971008)|WF_ACTION| None
12:26:48.53 (73974685)|WF_RULE_EVAL_END
12:26:48.53 (74027751)|WF_ACTIONS_END| None
12:26:48.53 (74035366)|CODE_UNIT_FINISHED|Workflow:Task
12:26:48.53 (75452920)|EXECUTION_FINISHED


 

HI.

 

I am following the Warehouse app Tutorial.

I am at Tutorial #7.

Just finished down-loading the Force.com IDE but don't know how to create a project.

The instruction are saying to select FILe->New but under File the only options I am getting are: Exit, Open File and Convert Line delimiters to...

 

Help will be much appreciated!

 

New to SF