• Steve Connelly
  • NEWBIE
  • 115 Points
  • Member since 2016
  • Business Analyst
  • Promontory Interfinancial Network LLC

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 16
    Replies
My trigger works and my Test Class have 85% coverage but I would like to know how to get a littl emore coverage.

Not so much for the coverage itself but for the knowlege of how to do this in the future.

My trigger runs for inserts and updates.

My test class covers the insert but not the update and i am not at all; sure how to do both.

Here is the trigger:
trigger createOqNew on Opportunity (after insert, after update) 

//trigger
{ 
   
    // try
    try{
           
        Id recordTypeId =
        Schema.SObjectType.Opportunity.getRecordTypeInfosByDeveloperName().get('CDARS_ICS_Prospect').getRecordTypeId();
        
        List <Open_Quarter__c> createOpenQuarter = new List <Open_Quarter__c>();
        List <Open_Quarter__c> deleteOpenQuarter = new List <Open_Quarter__c>();
        Set <Id> processedOpportunities = new Set <Id>();
        
        // for loop 1
        for (Opportunity opportunityList : Trigger.new) {   
            
            // if loop 1
            if (opportunityList.RecordTypeId == recordTypeId) {
                
                // if loop 2
                if (Trigger.isInsert 
                    || (Trigger.isUpdate && opportunityList.Estimated_Start_Quarter__c != Trigger.oldMap.get(opportunityList.Id).Estimated_Start_Quarter__c)
                    || (Trigger.isUpdate && opportunityList.Estimated_Finish_Quarter__c != Trigger.oldMap.get(opportunityList.Id).Estimated_Finish_Quarter__c)){
                                          
                    Decimal year = opportunityList.Start_Year__c;
                    Decimal quarter = opportunityList.Start_Quarter__c;
                    Decimal span = opportunityList.Quarters_Spanned_op__c;
                    processedOpportunities.add(OpportunityList.Id);
                        
                    //for loop 2
                    for (Integer counter = 0; counter < span; counter++)
                    {
                        Open_Quarter__c oq           		= new Open_Quarter__C();
                        oq.Amount_Per_Quarter_oq__c  		= opportunityList.Amount_per_Quarter_op__c;
                        oq.Estimated_Finish_Quarter_OQ__c   = opportunityList.Estimated_Finish_Quarter__c;
                        oq.Estimated_Start_Quarter_OQ__c	= opportunityList.Estimated_Start_Quarter__c;
                        oq.Name                      		= year+'-'+'Q'+quarter;
                        oq.Opportunity_Name_oq__c    		= opportunityList.Id;
                        
                        createOpenQuarter.add(oq);
                        quarter++;
                        
                        // if loop 3
                        if (quarter > 4) {
                            quarter = 1;
                            year++;
                        } //end if loop 3                       
                    } //end for loop 2      
                } //end if loop 2
            } //end if loop 1
        } //end for loop 1
        deleteOpenQuarter.addAll ([SELECT Id, Name FROM Open_Quarter__c WHERE Opportunity_Name_oq__c IN :processedOpportunities]);
        
        // if loop 4
        if (deleteOpenQuarter.isEmpty()==false){
            Database.delete (deleteOpenQuarter,false);
        } // end if loop 4
        
        // if loop 5
        if(createOpenQuarter.isEmpty()==false){
            Database.insert (createOpenQuarter,false);
        } // end if loop 5
    } // end try
    
    //catch
    catch (Exception e){
        //e.getMessage()
            //e.getLineNumber()
            throw e;
    } // end catch
} // end trigger
And here is the test class:
@isTest
public class TestCreateOqNew {
    
    @isTest static void testForCreateOQ() {
        
        Account acct = new Account(Name='Steve Test Account',
                                   recordTypeId='01241000001I8KBAA0',
                                   Service_Membership__c='Non-Member',
                                   Type='Bank');
        insert acct;
        
        Opportunity opp = new Opportunity(name=acct.Name + 'Opportunity',
                                          recordTypeId='01241000001USq9AAG',
                                          StageName='Prospecting',
                                          CloseDate=System.today().addMonths(6),
                                          Estimated_Finish_Quarter__c=System.today().addMonths(6),
                                          Estimated_Start_Quarter__c=System.today(),
                                          AccountId=acct.Id,
                                          Objective__c='Onboard - New',
                                          Amount=987654321,
                                          LeadSource='Webinar',
                                          Product_Type__c='CDARS Reciprocal');
        
        
        Test.startTest();
        insert opp;
        List<Open_Quarter__c> quarters = [SELECT Id, Name, Amount_Per_Quarter_oq__c, Estimated_Finish_Quarter_OQ__c, Estimated_Start_Quarter_OQ__c  , Opportunity_Name_oq__c FROM Open_Quarter__c ORDER BY Name];
        Test.stopTest();
        
        
        System.assertEquals(3, quarters.size());
        System.assertEquals('2020-Q2', quarters[0].name);            
        
    }
}

This is the main bit that is not covered:
|| (Trigger.isUpdate && opportunityList.Estimated_Start_Quarter__c != Trigger.oldMap.get(opportunityList.Id).Estimated_Start_Quarter__c)
                    || (Trigger.isUpdate && opportunityList.Estimated_Finish_Quarter__c != Trigger.oldMap.get(opportunityList.Id).Estimated_Finish_Quarter__c)){

(the "OR" parts).

Any tips on how to cover the update as well as the insert?

Thanks much,
Steve​​​​​​​​​​​​​​
 
I have an apex trigger the creates custom object records from an opportunity when the opp is ceated or when the close date is updated.

So far so good.

I have a new wrinkle and I am not sure how to apprach it.

When the opp close date is updated, I need the trigger to delete any of the custom object records it created in the earlier pass and then create new ones as normal.

Any suggestions on how to come at this?

Thanks much,
Steve
Good afternoon all,

I am new to programming and could use a little help with something.

I have a trigger where I need to find and use a custom object record that has the same field value as the opp that fires the trigger.

The Opp have a custom formula field that shows the quarter when the opp was opened. (Q2-2019).

I need to use that value to find a record in a custom object that has that same value in one of it's field.

Note, there will never be more than one match.

But I have no idea how to do that.

Can anyone offer me some suggestions?

Thanks much,
Steve
I am new to coding in general and to Apex in particular so any help I can get is greatly appreciated.

I am building a trigger that will create a new custom object record from an opportunity.

I plan to use process builder to fire the trigger when a particular opp type is created or when a particular field in that opp is updated.

I want the new record to be related to the Opp so i want to pull the Opp ID and some of the fields into the trigger to use in the new record.

How do i pull that specific data in?

Like I said, I am new at this but willing to work and learn.

Best regards,
Steve
 
Working in Lightning....

I am new to APEX. I nee dto build a trigger to create a custom object record from an Opportunity when a new Opp is created or the Close date changes.

I need to use fields from the Opp and from another custom object in the new record.

Can anyone point me to an article or some basic code to get me started?

There is more to this but I just want to get to whewre I can create the new record first. Sort of a learn by doing process.

Any help or suggestions is greatly appreciated.

Best regards,
Steve
Working in Process Builder. I need to extract two pieces of asystem generated email and place them in fields using formulas or regex.

The email is generated by an external suystem and sent to Salesforce where it generates a case. The emails are structured similarly with only the username and account info cahnging from email to email. Note that the username from this external system will often be an email address but will not always be. The usernames in this external system do not have a direct correlation to users/contacts in Salesforce.

Here is the section of the email I am working with:

RSBSA login credentials We will call you soon to provide you with a temporary password. * Institution Name: ABC Corporation (12345) * Name: Smith Mary * Username: msmith@abccorporation.com<mailto:msmith@abccorporation.com> * User Role: Security Admin * E-mail: msmith@abccorporation.com<mailto:msmith@abccorporation.com>

The parts that I need to extract are the account ID (bold itallic - five digit number) and the username (in this example an email address).

In about 1/2 the cases the username will not be an email address and as such will not be followed by the "mailto" tag.

Since the account ID is preceded by an account name of unknown length and the username is of an unknown length, I am having a hard time isolating these bits.

Does anyone out there have any suggestions on how to approach this? It has been suggested that I use Apex to parse the whole email but that is just not in my wheelhouse so I am trying to find other ways to get this done.

Any suggestions?
Steve
Working in Lightning.

I would like to be able to view the code that Salesforce uses to launch flows in quick actions. It would help me understand how Salesforce manages this type of activity. i would like to replicate some of these actions in a lightning component.

Any suggestions?

Steve
Working in lightning. I have built a lightning component where i am able to open a modal window by having a user click on an image in the component as if it were a button.

So far, so good. 

What I need to do is launch a flow in that modal window when it opens and then have the modal close when the user clicks the finish button in the flow.

I have the flow name as well as the url, just not sure how to make it launch when the modal opens.

Any thoughts, suggestions, resoruces out there?

Thanks much,
Steve
We have installed Identity Connect on a new server and connected it to Active Directory and now we are tring to connect it to Salesforce. 

I created a connected app and configured the OAuth on it the way the implementation guide advises but I am getting OAuth errors when I try to complete the connection between Identity Connect, Active Directory and Salesforce.

Does anyone out there have any experience with this?

Steve
I have built a new App for end users to use to access HD services. I am building a new component to house large buttons that will launch flows that in turn will create new cases.

So far, so good.

When I click the buttons, the flow opens in a new tab. The user completes the steps and a case is created.

Again, all good.

I do not like the user experience with the new tab though. When they click the Finish button at the end, it just takes them back to the opening screen element and does not close the tab.

What I am looking for is an experience that is more like what i get when I launch a flow from say a contact record as a quick action. That opens the flow in a some sort of sub process like this:
User-added image

User-added image

User-added image
And the sub process then closes when the user clicks the Finish button.

Is there a way to accomplish this same effect from within this new component I have built? some HTML or other that will open the flow in this same sort of process? The best I have managed so far is the separate tab and that is just not doing it for me.

Any suggestions?
Best regards,
Steve
Working in Lightning...I am trying to add a flow URL to a lightning component. Here is what I have entered:
<div aura:id="container">
    <p><lightning:formattedUrl value="https://promnetwork--hd2sf--c.cs27.visual.force.com/flow/runtime.apexp?flowDevName=Security_Exception_Request&flowVersionId=301220000001I27"/></p>
    </div>

When I try to save the component, I get this error:
Failed to save HDFlowLauncher.cmp: c:HDFlowLauncher:22,2: ParseError at [row,col]:[23,2] Message: The markup in the document following the root element must be well-formed.: Source

This is a URL...I can't edit it and have it still work. I entered this as a Lightning Configured URL so i can't sort out the problem.

Any suggestions out there?
Thanks much,
Steve
I need to build a report in SF to replace a report that we used in SLX. The old SLX report is actually two reports. Page one is a matrix report and the rest of the pages are a summary report on the same data.

Both reports are pretty basic and easy to build. What I don't know id how to join these two reports into one so that the Matrix displays as page one with the summary report following?

Thoughts?
Sc
My trigger works and my Test Class have 85% coverage but I would like to know how to get a littl emore coverage.

Not so much for the coverage itself but for the knowlege of how to do this in the future.

My trigger runs for inserts and updates.

My test class covers the insert but not the update and i am not at all; sure how to do both.

Here is the trigger:
trigger createOqNew on Opportunity (after insert, after update) 

//trigger
{ 
   
    // try
    try{
           
        Id recordTypeId =
        Schema.SObjectType.Opportunity.getRecordTypeInfosByDeveloperName().get('CDARS_ICS_Prospect').getRecordTypeId();
        
        List <Open_Quarter__c> createOpenQuarter = new List <Open_Quarter__c>();
        List <Open_Quarter__c> deleteOpenQuarter = new List <Open_Quarter__c>();
        Set <Id> processedOpportunities = new Set <Id>();
        
        // for loop 1
        for (Opportunity opportunityList : Trigger.new) {   
            
            // if loop 1
            if (opportunityList.RecordTypeId == recordTypeId) {
                
                // if loop 2
                if (Trigger.isInsert 
                    || (Trigger.isUpdate && opportunityList.Estimated_Start_Quarter__c != Trigger.oldMap.get(opportunityList.Id).Estimated_Start_Quarter__c)
                    || (Trigger.isUpdate && opportunityList.Estimated_Finish_Quarter__c != Trigger.oldMap.get(opportunityList.Id).Estimated_Finish_Quarter__c)){
                                          
                    Decimal year = opportunityList.Start_Year__c;
                    Decimal quarter = opportunityList.Start_Quarter__c;
                    Decimal span = opportunityList.Quarters_Spanned_op__c;
                    processedOpportunities.add(OpportunityList.Id);
                        
                    //for loop 2
                    for (Integer counter = 0; counter < span; counter++)
                    {
                        Open_Quarter__c oq           		= new Open_Quarter__C();
                        oq.Amount_Per_Quarter_oq__c  		= opportunityList.Amount_per_Quarter_op__c;
                        oq.Estimated_Finish_Quarter_OQ__c   = opportunityList.Estimated_Finish_Quarter__c;
                        oq.Estimated_Start_Quarter_OQ__c	= opportunityList.Estimated_Start_Quarter__c;
                        oq.Name                      		= year+'-'+'Q'+quarter;
                        oq.Opportunity_Name_oq__c    		= opportunityList.Id;
                        
                        createOpenQuarter.add(oq);
                        quarter++;
                        
                        // if loop 3
                        if (quarter > 4) {
                            quarter = 1;
                            year++;
                        } //end if loop 3                       
                    } //end for loop 2      
                } //end if loop 2
            } //end if loop 1
        } //end for loop 1
        deleteOpenQuarter.addAll ([SELECT Id, Name FROM Open_Quarter__c WHERE Opportunity_Name_oq__c IN :processedOpportunities]);
        
        // if loop 4
        if (deleteOpenQuarter.isEmpty()==false){
            Database.delete (deleteOpenQuarter,false);
        } // end if loop 4
        
        // if loop 5
        if(createOpenQuarter.isEmpty()==false){
            Database.insert (createOpenQuarter,false);
        } // end if loop 5
    } // end try
    
    //catch
    catch (Exception e){
        //e.getMessage()
            //e.getLineNumber()
            throw e;
    } // end catch
} // end trigger
And here is the test class:
@isTest
public class TestCreateOqNew {
    
    @isTest static void testForCreateOQ() {
        
        Account acct = new Account(Name='Steve Test Account',
                                   recordTypeId='01241000001I8KBAA0',
                                   Service_Membership__c='Non-Member',
                                   Type='Bank');
        insert acct;
        
        Opportunity opp = new Opportunity(name=acct.Name + 'Opportunity',
                                          recordTypeId='01241000001USq9AAG',
                                          StageName='Prospecting',
                                          CloseDate=System.today().addMonths(6),
                                          Estimated_Finish_Quarter__c=System.today().addMonths(6),
                                          Estimated_Start_Quarter__c=System.today(),
                                          AccountId=acct.Id,
                                          Objective__c='Onboard - New',
                                          Amount=987654321,
                                          LeadSource='Webinar',
                                          Product_Type__c='CDARS Reciprocal');
        
        
        Test.startTest();
        insert opp;
        List<Open_Quarter__c> quarters = [SELECT Id, Name, Amount_Per_Quarter_oq__c, Estimated_Finish_Quarter_OQ__c, Estimated_Start_Quarter_OQ__c  , Opportunity_Name_oq__c FROM Open_Quarter__c ORDER BY Name];
        Test.stopTest();
        
        
        System.assertEquals(3, quarters.size());
        System.assertEquals('2020-Q2', quarters[0].name);            
        
    }
}

This is the main bit that is not covered:
|| (Trigger.isUpdate && opportunityList.Estimated_Start_Quarter__c != Trigger.oldMap.get(opportunityList.Id).Estimated_Start_Quarter__c)
                    || (Trigger.isUpdate && opportunityList.Estimated_Finish_Quarter__c != Trigger.oldMap.get(opportunityList.Id).Estimated_Finish_Quarter__c)){

(the "OR" parts).

Any tips on how to cover the update as well as the insert?

Thanks much,
Steve​​​​​​​​​​​​​​
 
I have an apex trigger the creates custom object records from an opportunity when the opp is ceated or when the close date is updated.

So far so good.

I have a new wrinkle and I am not sure how to apprach it.

When the opp close date is updated, I need the trigger to delete any of the custom object records it created in the earlier pass and then create new ones as normal.

Any suggestions on how to come at this?

Thanks much,
Steve
I am new to coding in general and to Apex in particular so any help I can get is greatly appreciated.

I am building a trigger that will create a new custom object record from an opportunity.

I plan to use process builder to fire the trigger when a particular opp type is created or when a particular field in that opp is updated.

I want the new record to be related to the Opp so i want to pull the Opp ID and some of the fields into the trigger to use in the new record.

How do i pull that specific data in?

Like I said, I am new at this but willing to work and learn.

Best regards,
Steve
 
Working in Lightning....

I am new to APEX. I nee dto build a trigger to create a custom object record from an Opportunity when a new Opp is created or the Close date changes.

I need to use fields from the Opp and from another custom object in the new record.

Can anyone point me to an article or some basic code to get me started?

There is more to this but I just want to get to whewre I can create the new record first. Sort of a learn by doing process.

Any help or suggestions is greatly appreciated.

Best regards,
Steve
I am so close on this one I think. I have built an invocable method to pass two contacts from a flow into Apex to merge the contacts but I am stuck in the part of the code to pass the IDs into the merge command.

Here is the code:

User-added image

The code indicates that there the survivorCont and mergeCont variables do not exist.

I feel like I am very close on this one but could ureally use some help taking this accross the finish line.

Any thought sout there on this one?
Thanks much
Steve
Working in Lightning.

I would like to be able to view the code that Salesforce uses to launch flows in quick actions. It would help me understand how Salesforce manages this type of activity. i would like to replicate some of these actions in a lightning component.

Any suggestions?

Steve
Working in lightning. I have built a lightning component where i am able to open a modal window by having a user click on an image in the component as if it were a button.

So far, so good. 

What I need to do is launch a flow in that modal window when it opens and then have the modal close when the user clicks the finish button in the flow.

I have the flow name as well as the url, just not sure how to make it launch when the modal opens.

Any thoughts, suggestions, resoruces out there?

Thanks much,
Steve
We have installed Identity Connect on a new server and connected it to Active Directory and now we are tring to connect it to Salesforce. 

I created a connected app and configured the OAuth on it the way the implementation guide advises but I am getting OAuth errors when I try to complete the connection between Identity Connect, Active Directory and Salesforce.

Does anyone out there have any experience with this?

Steve
Working in Lightning...I am trying to add a flow URL to a lightning component. Here is what I have entered:
<div aura:id="container">
    <p><lightning:formattedUrl value="https://promnetwork--hd2sf--c.cs27.visual.force.com/flow/runtime.apexp?flowDevName=Security_Exception_Request&flowVersionId=301220000001I27"/></p>
    </div>

When I try to save the component, I get this error:
Failed to save HDFlowLauncher.cmp: c:HDFlowLauncher:22,2: ParseError at [row,col]:[23,2] Message: The markup in the document following the root element must be well-formed.: Source

This is a URL...I can't edit it and have it still work. I entered this as a Lightning Configured URL so i can't sort out the problem.

Any suggestions out there?
Thanks much,
Steve
User-added image

This error i am getting while saving the code...please help me how to remove this error
Hi there, I've got a very specific design outcome I'm trying to achieve in Lightning and I can't find any info relating to this on any of the usual channels.

I want to present a flow as a modal dialog box from a list view. This would mean a user could select multiple records, and run through the flow for each of the items. I have built a version that meets these criteria with the exception of presenting the flow in a modal dialog over the current list. Although this final requirement isn't critical to the functionality of the process, it is important to keep the experience consistent with other lightning processes.

I understand this could be completed through JS if I was using Classic, but our org has migrated to Lightning a while back and won't be moving.

Also, interestingly I can get the desired modal display using an Action, but this can't be added to a list view (only a detail view) in my understanding.


Does anyone have any suggestions as to how this could be achieved? Thanks in advance!




This is the current process:

Visualforce Page, launched by list view button
<apex:page standardController="Contact" lightningStyleSheets="true" tabStyle="Contact" recordSetVar="AllContacts" >
        <!-- Add below each field you reference in your Flow -->   
        <apex:repeat value="{!AllContacts}" var="row" rendered="false">
            {!row.Id}
        </apex:repeat>
        <!-- Runs your Flow -->   
        <flow:interview name="Outbound_Call_Flow_Contact_v2" 
            finishLocation="{!URLFOR($Action.Contact.Tab, $ObjectType.Contact)}">
            <apex:param name="selectedContacts" value="{!Selected}"/>
        </flow:interview>
</apex:page>

Button settings
User-added image


List view
User-added image


Flow once launched (takes its own page, when I would like it to present modally)
User-added image

Desired presentation of flow
User-added image 
I need to build a report in SF to replace a report that we used in SLX. The old SLX report is actually two reports. Page one is a matrix report and the rest of the pages are a summary report on the same data.

Both reports are pretty basic and easy to build. What I don't know id how to join these two reports into one so that the Matrix displays as page one with the summary report following?

Thoughts?
Sc