• Nevin O'Regan 3
  • NEWBIE
  • 80 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 40
    Questions
  • 63
    Replies
I have a custom object called Year__c which is related to the Opportunity object.
On the Opp object I have a custom picklist field Period__c where has values 1 to 10. 
What I am trying to do is to automatically create Year__c records based on the Period__c picklist field. So if a user selects the value "2" in the Period__c field then I would like 2 Year__c records to be created.
Along with this I have a Start Date and End Date on the Opportunity and on the Year__c object. I need the Start Date in Year 1 record to = the Start Date on the Opportunity, the end Date should be 12 months after the Start Date on Year 1. On Year 2 the Start Date should be the day of the End Date of Year 1 and the End Date of Year 2 should = the End Date of the Opportunity. 

Would anyone be able to help me with this?
Hi guys,

I have created a trigger on the OpportunityLineItemSchedule record to update fields in the parent OpportunityLineItem record. However it is not updating the fields in the OpportunityLineItem to blank values if I delete a scedule. Can anyone help me with this?

trigger MapMontsOnSchedule on OpportunityLineItemSchedule (after insert, before update) {
    
    // UPDATED: Must handle multiple children for a single parent
    // Instead of a single OpportunityLineItem, hold a list of them
    Map<Id,List<OpportunityLineItemSchedule>> MapMonths = new Map<Id, List<OpportunityLineItemSchedule>>();
    
    // Have a temp list ready for looping
    List<OpportunityLineItemSchedule> tempOlisList;
    
    // Now populate the months map
    for(OpportunityLineItemSchedule sch : trigger.new) {
        // Check if the map already has an entry for the parent Id (key)
        if(MapMonths.containsKey(sch.OpportunityLineItemId)) {
            // If it does, then update the list with the new value (so it will not override the previous value)
            tempOlisList = MapMonths.get(sch.OpportunityLineItemId);
            tempOlisList.add(sch);
            MapMonths.put(sch.OpportunityLineItemId, tempOlisList);
        } else {
            // Otherwise, we will create a new entry in the map with a list value of just the current iteration's OLIS
            tempOlisList = new List<OpportunityLineItemSchedule>();
            tempOlisList.add(sch);
            MapMonths.put(sch.OpportunityLineItemId, tempOlisList);
        }
    }

    List<OpportunityLineItem> OppLineItemList = new List<OpportunityLineItem>();
    for(OpportunityLineItem oli:[
        Select id, January__c,February__c, March__c, April__c, May__c, June__c, July__c, August__c, September__c, October__c, November__c,December__c 
        From OpportunityLineItem 
        Where Id IN :MapMonths.Keyset()
    ]) {
        // Then, the following is the updated if statement inside your for loop
        if(MapMonths.containsKey(oli.id)) {
            
            // UPDATE: Because we have a list of children now, we will need to loop through all of them to assign values to each month before moving on to the next Opportunity Line Item
            // Create a for loop to go through the list of children
            for(OpportunityLineItemSchedule olis : MapMonths.get(oli.id)) {
                
                // Create a switch statement to check what value is the Month
                switch on olis.Month__c {
                    // If the opportunity line item schedule's Month field was January
                    when 'January' {
                        // Then assign the opportunity line item's January field to the opportunity line item schedule's quantity
                        oli.January__c = olis.Quantity;
                    }
                    when 'February' {
                        oli.February__c = olis.Quantity;
                    }
                    when 'March' {
                        oli.March__c = olis.Quantity;
                    }
                    when 'Apr' {
                        oli.April__c = olis.Quantity;
                    }
                    when 'May' {
                        oli.May__c = olis.Quantity;
                    }
                    when 'June' {
                        oli.June__c = olis.Quantity;
                    }
                    when 'July' {
                        oli.July__c = olis.Quantity;
                    }
                    when 'August' {
                        oli.August__c = olis.Quantity;
                    }
                    when 'September' {
                        oli.September__c = olis.Quantity;
                    }
                    when 'October' {
                        oli.October__c = olis.Quantity;
                    }
                    when 'November' {
                        oli.November__c = olis.Quantity;
                    }
                    when 'December' {
                        oli.December__c = olis.Quantity;
                    }
                    // If it did not find any matches
                    when else {
                        // EDIT: do not put anything here for now
                        // You can leave this empty or put something in here to handle cases where the Month field is NOT the name of the month
                        // e.g. Month field was for some reason populated with 'Apple'
                    }
                }
            }
            OppLineItemList.add(oli);
        }
    }
    update OppLineItemList;
}
Hi guys, 

I have built my first trigger with the help of this group. I'm hoping someone can help me out building a test class for it so that I can deploy it into production. The trigger basically maps fields from OppLineItemSchedule to the OppLineItem

trigger MapMontsOnSchedule on OpportunityLineItemSchedule (after insert, before update) {
    
    // UPDATED: Must handle multiple children for a single parent
    // Instead of a single OpportunityLineItem, hold a list of them
    Map<Id,List<OpportunityLineItemSchedule>> MapMonths = new Map<Id, List<OpportunityLineItemSchedule>>();
    
    // Have a temp list ready for looping
    List<OpportunityLineItemSchedule> tempOlisList;
    
    // Now populate the months map
    for(OpportunityLineItemSchedule sch : trigger.new) {
        // Check if the map already has an entry for the parent Id (key)
        if(MapMonths.containsKey(sch.OpportunityLineItemId)) {
            // If it does, then update the list with the new value (so it will not override the previous value)
            tempOlisList = MapMonths.get(sch.OpportunityLineItemId);
            tempOlisList.add(sch);
            MapMonths.put(sch.OpportunityLineItemId, tempOlisList);
        } else {
            // Otherwise, we will create a new entry in the map with a list value of just the current iteration's OLIS
            tempOlisList = new List<OpportunityLineItemSchedule>();
            tempOlisList.add(sch);
            MapMonths.put(sch.OpportunityLineItemId, tempOlisList);
        }
    }

    List<OpportunityLineItem> OppLineItemList = new List<OpportunityLineItem>();
    for(OpportunityLineItem oli:[
        Select id, January__c,February__c, March__c, April__c, May__c, June__c, July__c, August__c, September__c, October__c, November__c,December__c 
        From OpportunityLineItem 
        Where Id IN :MapMonths.Keyset()
    ]) {
        // Then, the following is the updated if statement inside your for loop
        if(MapMonths.containsKey(oli.id)) {
            
            // UPDATE: Because we have a list of children now, we will need to loop through all of them to assign values to each month before moving on to the next Opportunity Line Item
            // Create a for loop to go through the list of children
            for(OpportunityLineItemSchedule olis : MapMonths.get(oli.id)) {
                
                // Create a switch statement to check what value is the Month
                switch on olis.Month__c {
                    // If the opportunity line item schedule's Month field was January
                    when 'January' {
                        // Then assign the opportunity line item's January field to the opportunity line item schedule's quantity
                        oli.January__c = olis.Quantity;
                    }
                    when 'February' {
                        oli.February__c = olis.Quantity;
                    }
                    when 'March' {
                        oli.March__c = olis.Quantity;
                    }
                    when 'Apr' {
                        oli.April__c = olis.Quantity;
                    }
                    when 'May' {
                        oli.May__c = olis.Quantity;
                    }
                    when 'June' {
                        oli.June__c = olis.Quantity;
                    }
                    when 'July' {
                        oli.July__c = olis.Quantity;
                    }
                    when 'August' {
                        oli.August__c = olis.Quantity;
                    }
                    when 'September' {
                        oli.September__c = olis.Quantity;
                    }
                    when 'October' {
                        oli.October__c = olis.Quantity;
                    }
                    when 'November' {
                        oli.November__c = olis.Quantity;
                    }
                    when 'December' {
                        oli.December__c = olis.Quantity;
                    }
                    // If it did not find any matches
                    when else {
                        // EDIT: do not put anything here for now
                        // You can leave this empty or put something in here to handle cases where the Month field is NOT the name of the month
                        // e.g. Month field was for some reason populated with 'Apple'
                    }
                }
            }
            OppLineItemList.add(oli);
        }
    }
    update OppLineItemList;
}
Hi guys,

I have created 12 custom number fields in the OppLineItem, each labeled a month of the year. I have also created a custom formula text field in the OppLineItemSchedule object called Month which defines the month based on the scheduled date.
I am trying to create a trigger to map the Quantity value from the related OppLineItemSchedule record to the relevant OppLineItem Month field. I have created the below trigger but the issue is that it is populating every Month field on the OppLineItem with a value even if there is not a related OppLineItemSch Quantity. 

trigger MapMontsOnSchedule on OpportunityLineItemSchedule (after insert, before update) {
    Map<Id,Integer> MapMonths = new Map<Id, Integer>();
 
    for(OpportunityLineItemSchedule sch:trigger.new) {
         MapMonths.put(sch.OpportunityLineItemId, Integer.valueOf(sch.Quantity));
    }
 
    List<OpportunityLineItem> OppLineItemList = new List<OpportunityLineItem>();
 
    for(OpportunityLineItem oli:[Select id, January__c, 
                                            February__c, 
                                            March__c, 
                                            April__c, 
                                            May__c, 
                                            June__c, 
                                            July__c, 
                                            August__c, 
                                            September__c, 
                                            October__c, 
                                            November__c,
                                            December__c From OpportunityLineItem Where Id IN :MapMonths.Keyset()])
    {
        if(MapMonths.containsKey(oli.id))
        {
            OppLineItemList.add(new OpportunityLineItem(Id = oli.id, January__c=MapMonths.get(oli.id), 
                                                                     February__c=MapMonths.get(oli.id),
                                                                        March__c=MapMonths.get(oli.id), 
                                                                     April__c=MapMonths.get(oli.id),
                                                                     May__c=MapMonths.get(oli.id),
                                                                     June__c=MapMonths.get(oli.id),
                                                                     July__c=MapMonths.get(oli.id),
                                                                     August__c=MapMonths.get(oli.id),
                                                                     September__c=MapMonths.get(oli.id),
                                                                     October__c=MapMonths.get(oli.id),
                                                                     November__c=MapMonths.get(oli.id),
                                                                     December__c=MapMonths.get(oli.id)));
                                                                                    
        }
    }
    update OppLineItemList;
}
Hi guys,

I am relatively new to writing triggers and I am running into an issue with one that I am currently working on. 

I would like to update custom fields in the OpportunityLineItem object with the value from the OpportunityLineItemSchedule.Quantity field. I have 12 custom fields in the OpportunityLineItem for each month of the year, Jan to Dec.

Here is the code that I have so far but I am running into an error "Method does not exist or incorrect signature: void put(Id, Decimal) from the type Map<Id,Integer>" on Line 6.

trigger MapMontsOnSchedule on OpportunityLineItemSchedule (after insert, before update) {
Map<Id,Integer> OpportunityLineItemIdwithOpportunityLineItemScheduleField = new Map<Id, Integer>();
 
    for(OpportunityLineItemSchedule sch:trigger.new)
    {
        OpportunityLineItemIdwithOpportunityLineItemScheduleField.put(sch.OpportunityLineItemId, sch.Quantity);
    }
 
    List<OpportunityLineItem> listUpdatedOpportunityLineItem = new List<OpportunityLineItem>();
 
    for(OpportunityLineItem oli:[Select id, January__c From OpportunityLineItem Where Id IN :OpportunityLineItemIdwithOpportunityLineItemScheduleField.Keyset()])
    {
        if(OpportunityLineItemIdwithOpportunityLineItemScheduleField.containsKey(oli.id))
        {
            listUpdatedOpportunityLineItem.add(new OpportunityLineItem(Id = oli.id, January__c=OpportunityLineItemIdwithOpportunityLineItemScheduleField.get(oli.id)));
        }
    }
    update listUpdatedOpportunityLineItem;
}

 
Hi guys,

I have custom formula fields on the OpportunityLineItemSchedule object which display a month based on the month the scheduled date falls within. 

I have created 12 custom fields on the OppLine object, each labeled one of the months of the year. I need a way of rolling up the Quantity of the the related schedules to the corresponding custom fields on the OppLine. 

Has anyone created anything similar in the past?
I have to Auto Number fields on the Opportunity and the Quote objects. They are both running using the same format which is confusing for users. I'd like to identify the records that have matching Auto Number field values. How can I achieve this through SOQL?
I have an Approval_Status__c field on the Opportunity. When a related OpportunityLineItem.UnitPrice is below the List Price I need this to update to 'Needs Approval'. If the Unit Price is above the List Price then the Approval_Status__c field should be null. 
Can anyone give me some help with wrighting a trigger for this?
Hi Guys,

We have a need to be able to add more than one pricebook to an Opportunity. I know that this is not possible out of the box but is there a way that this can be achieved through custom development? Has anyone implemented something similiar in the past?

 
Hi guys,

I have created two lenses which calculate the No. of rows after I apply a couple of filters to the dataset. One gives me the Full Allocation and the other gives me Partial Allocation. 

Partial
q = load "FillRatio201902";
q = filter q by 'BO_Qty' > 0;
q = filter q by 'Status' != "Cancelled";
q = filter q by 'Formula' < 0;
q = group q by all;
q = foreach q generate count() as 'count';
q = limit q 2000;

Full Allocation
q = load "FillRatio201902";
q = filter q by 'BO_Qty' == 0;
q = filter q by 'Status' != "Cancelled";
q = filter q by date('Allocated_Date_Year', 'Allocated_Date_Month', 'Allocated_Date_Day') in [dateRange([1970,10,6], [2019,3,3])];
result = group q by all;
result = foreach result generate count(q) as 'A', sum(q.'BO_Qty') as 'B';
result = limit result 2000;

I now need to calculate a 'Fill Ratio' which includes the results of the Full Allocation and Partial Allocation in it.
Fill Ratio = Full Allocation + (Partial * 0.5) / Total No. Of Rows

Is it even possible to calculate this through SAQL?
Hi guys,

I am trying to filter out data to only show lines where the dates in two columns are matching in einstein analytics.
Can anyone help me with this?
Is it possible to override a file? The requirement is based around Conga Composer. When a user generates a document it is automatically saved to the record. The business would like to override the same file. I know there is a version control function that can be used but this is not required. 
Hi guys,

Is it possible to connect Einstein Analytics to a .csv file in a shared folder on a windows server?
Hi guys,

I'd like to be able to create multiple contacts from within one component and relate them to the same account. 
The component will added to a Contact where type = Main Applicant. When a user clicks on a "Create" button they should be able to create as many contacts from here as they need to capture Spouse, Children etc. 
Has anyone developed something similar? 
I have created custom buttons which I would only make available based on the Contact.Type field value selected. Is it possible to create a custom component where I can group these buttons?
I have one currency field which is a manual input "Total_Commission__c". The commission is paid out at 3 stages and is a % of the Total_Commision_c. So what I have done is created 3 custom % fields and 3 custom formula currency fields. Based on the number a user inputs into the % field it calculates the commision for that stage.
Payment no.1 might be 50% of the Total Commission but it also might be 100% of the Total Commission. What I'd like is a field to show if the commision has been paid in full. So If Payment 1 = 50% then the field displays a simple "No". If Payment 1 = 100% then it should show "Yes". However, if Payment 1 = 50% then it should show as "No", but if Payment 1 = 50% and Payment 2 = 50% then the formula field should show as "Yes".

Sorry it's a bit confusing but would anyone have a solution?
Has anyone got simple examples of where they were able to add a 3rd column to a section in Lightning? 
 
I have a lookup field in the Contact record which looks up to a custom object Application__c. How can I show fields in a component related to the Application record? Is there a standard way of doing this?
I have create a custom button on a custom object called Application__c, that launces a flow in lightning. The flow creates a contact record from within the custom object Application__c. 
I would like the created contact to be automatically related to the Application where it was created from.
Below is the custom button. Can anyone help me with this?

<apex:page standardController="Application__c ">
    <flow:interview name="ContactCreate" finishLocation="/{!Application__c.Id}"></flow:interview>
      <apex:param name="varRecordId" value="{!Application__c.Id}"/>
</apex:page>
I'm in the process of building a flow which includes the contact object. The object has 5 record types so I was hoping to show a screen where a user could select the type of record and then proceed to the next screen.

I can't seem to find any online material that could guide me through this. Does anyone have experience implementing this kind of solution?
I have created custom buttons which I would only make available based on the Contact.Type field value selected. Is it possible to create a custom component where I can group these buttons?
If I create a Big Object and then delete it is that counted towards the 100 big object limit? 
I have a custom object called Year__c which is related to the Opportunity object.
On the Opp object I have a custom picklist field Period__c where has values 1 to 10. 
What I am trying to do is to automatically create Year__c records based on the Period__c picklist field. So if a user selects the value "2" in the Period__c field then I would like 2 Year__c records to be created.
Along with this I have a Start Date and End Date on the Opportunity and on the Year__c object. I need the Start Date in Year 1 record to = the Start Date on the Opportunity, the end Date should be 12 months after the Start Date on Year 1. On Year 2 the Start Date should be the day of the End Date of Year 1 and the End Date of Year 2 should = the End Date of the Opportunity. 

Would anyone be able to help me with this?
Hi guys,

I have created 12 custom number fields in the OppLineItem, each labeled a month of the year. I have also created a custom formula text field in the OppLineItemSchedule object called Month which defines the month based on the scheduled date.
I am trying to create a trigger to map the Quantity value from the related OppLineItemSchedule record to the relevant OppLineItem Month field. I have created the below trigger but the issue is that it is populating every Month field on the OppLineItem with a value even if there is not a related OppLineItemSch Quantity. 

trigger MapMontsOnSchedule on OpportunityLineItemSchedule (after insert, before update) {
    Map<Id,Integer> MapMonths = new Map<Id, Integer>();
 
    for(OpportunityLineItemSchedule sch:trigger.new) {
         MapMonths.put(sch.OpportunityLineItemId, Integer.valueOf(sch.Quantity));
    }
 
    List<OpportunityLineItem> OppLineItemList = new List<OpportunityLineItem>();
 
    for(OpportunityLineItem oli:[Select id, January__c, 
                                            February__c, 
                                            March__c, 
                                            April__c, 
                                            May__c, 
                                            June__c, 
                                            July__c, 
                                            August__c, 
                                            September__c, 
                                            October__c, 
                                            November__c,
                                            December__c From OpportunityLineItem Where Id IN :MapMonths.Keyset()])
    {
        if(MapMonths.containsKey(oli.id))
        {
            OppLineItemList.add(new OpportunityLineItem(Id = oli.id, January__c=MapMonths.get(oli.id), 
                                                                     February__c=MapMonths.get(oli.id),
                                                                        March__c=MapMonths.get(oli.id), 
                                                                     April__c=MapMonths.get(oli.id),
                                                                     May__c=MapMonths.get(oli.id),
                                                                     June__c=MapMonths.get(oli.id),
                                                                     July__c=MapMonths.get(oli.id),
                                                                     August__c=MapMonths.get(oli.id),
                                                                     September__c=MapMonths.get(oli.id),
                                                                     October__c=MapMonths.get(oli.id),
                                                                     November__c=MapMonths.get(oli.id),
                                                                     December__c=MapMonths.get(oli.id)));
                                                                                    
        }
    }
    update OppLineItemList;
}
Hi guys,

I am relatively new to writing triggers and I am running into an issue with one that I am currently working on. 

I would like to update custom fields in the OpportunityLineItem object with the value from the OpportunityLineItemSchedule.Quantity field. I have 12 custom fields in the OpportunityLineItem for each month of the year, Jan to Dec.

Here is the code that I have so far but I am running into an error "Method does not exist or incorrect signature: void put(Id, Decimal) from the type Map<Id,Integer>" on Line 6.

trigger MapMontsOnSchedule on OpportunityLineItemSchedule (after insert, before update) {
Map<Id,Integer> OpportunityLineItemIdwithOpportunityLineItemScheduleField = new Map<Id, Integer>();
 
    for(OpportunityLineItemSchedule sch:trigger.new)
    {
        OpportunityLineItemIdwithOpportunityLineItemScheduleField.put(sch.OpportunityLineItemId, sch.Quantity);
    }
 
    List<OpportunityLineItem> listUpdatedOpportunityLineItem = new List<OpportunityLineItem>();
 
    for(OpportunityLineItem oli:[Select id, January__c From OpportunityLineItem Where Id IN :OpportunityLineItemIdwithOpportunityLineItemScheduleField.Keyset()])
    {
        if(OpportunityLineItemIdwithOpportunityLineItemScheduleField.containsKey(oli.id))
        {
            listUpdatedOpportunityLineItem.add(new OpportunityLineItem(Id = oli.id, January__c=OpportunityLineItemIdwithOpportunityLineItemScheduleField.get(oli.id)));
        }
    }
    update listUpdatedOpportunityLineItem;
}

 
Hi guys,

I have custom formula fields on the OpportunityLineItemSchedule object which display a month based on the month the scheduled date falls within. 

I have created 12 custom fields on the OppLine object, each labeled one of the months of the year. I need a way of rolling up the Quantity of the the related schedules to the corresponding custom fields on the OppLine. 

Has anyone created anything similar in the past?
Hi guys,

I'd like to be able to create multiple contacts from within one component and relate them to the same account. 
The component will added to a Contact where type = Main Applicant. When a user clicks on a "Create" button they should be able to create as many contacts from here as they need to capture Spouse, Children etc. 
Has anyone developed something similar? 
I have created custom buttons which I would only make available based on the Contact.Type field value selected. Is it possible to create a custom component where I can group these buttons?
Has anyone got simple examples of where they were able to add a 3rd column to a section in Lightning? 
 
If I create a Big Object and then delete it is that counted towards the 100 big object limit?