-
ChatterFeed
-
0Best Answers
-
2Likes Received
-
0Likes Given
-
52Questions
-
81Replies
Error When Adding A Custom Component To Community Page
Hi guys,
I've created a custom screen flow and I want to add it to a community page, launched from a custom button on the Homepage.
The flow guides users through creating a case. I am getting the following error when I add the component to the page: "Action failed: c:CustomCaseCommunityComponent$controller$init [flowData is not defined]"
This is my component.
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,forceCommunity:availableForAllPageTypes,force:hasRecordId,force:lightningQuickActionWithoutHeader" access="global">
<aura:handler name="init" value="{!this}" action="{!c.init}"/>
<lightning:flow aura:id="flowData"/>
</aura:component>
({
init : function (component) {
var flow = component.find(flowData);
flow.startFlow(CaseFlow);
},
})
I've created a custom screen flow and I want to add it to a community page, launched from a custom button on the Homepage.
The flow guides users through creating a case. I am getting the following error when I add the component to the page: "Action failed: c:CustomCaseCommunityComponent$controller$init [flowData is not defined]"
This is my component.
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,forceCommunity:availableForAllPageTypes,force:hasRecordId,force:lightningQuickActionWithoutHeader" access="global">
<aura:handler name="init" value="{!this}" action="{!c.init}"/>
<lightning:flow aura:id="flowData"/>
</aura:component>
({
init : function (component) {
var flow = component.find(flowData);
flow.startFlow(CaseFlow);
},
})
-
- Nevin O'Regan 3
- April 06, 2020
- Like
- 0
- Continue reading or reply
I want a picklist field to move to the next value in a flow
Hi guys,
I have a custom object called Year__c whis has a picklist field called Period__c which has values 1 - 10. I have built a screen flow which includes the creation of a Year__c object.
Each time a new Year__c record is created I want the Period__c to automatically update with the next picklist value.
How can I do this in a flow?
I have a custom object called Year__c whis has a picklist field called Period__c which has values 1 - 10. I have built a screen flow which includes the creation of a Year__c object.
Each time a new Year__c record is created I want the Period__c to automatically update with the next picklist value.
How can I do this in a flow?
-
- Nevin O'Regan 3
- March 24, 2020
- Like
- 0
- Continue reading or reply
Help With A Roll Up Trigger
Hi guys,
I'm looking for some help with a trigger that I have built on a custom object which has a lookup field to itself.
I object Payment__c has a custom picklist field Payment_Status__c with a value of 'Cleared'. I only want the Recovered_Amt_Ex_VAT__c field of the parent Payment__c to update when the child Payment__c status is updated to 'Cleared'. I have built the below code but it is updating the parent Payment__c regardless of the status.
NOTE: there will be nested child Payment__c scenarios.
//Rolls up the related payment total amounts to parent payment record //
trigger RecoveredAmountOnPayment on Payment__c (after insert, after update, after delete, after undelete) {
Set<ID> setID = new Set<ID>();
List<Payment__c> lstPay = new List<Payment__c>();
if(trigger.isinsert || trigger.isundelete){
for(Payment__c p : trigger.new){
setID.add(p.Replaced_Payment__c);
}
}
else if(trigger.isDelete){
for(Payment__c p : trigger.old){
setID.add(p.Replaced_Payment__c);
}
}
else if(trigger.isUpdate){
for(Payment__c p : trigger.new){
if(p.Replaced_Payment__c != null){
if(trigger.oldmap.get(p.id).Replaced_Payment__c != p.Replaced_Payment__c){
setID.add(p.Replaced_Payment__c);
}
}
setID.add(trigger.oldmap.get(p.id).Replaced_Payment__c);
}
}
if(setid.size() > 0){
lstPay = [Select id,Recovered_Amt_Ex_VAT__c ,(Select id,Payment_Amount__c from Replaced__r) from Payment__c where id IN : setID];
}
for(Payment__c pay : lstPay){
Decimal val = 0;
for(Payment__c rep : pay.Replaced__r){
val += rep.Payment_Amount__c;
}
pay.Recovered_Amt_Ex_VAT__c = val;
}
update lstPay;
}
I'm looking for some help with a trigger that I have built on a custom object which has a lookup field to itself.
I object Payment__c has a custom picklist field Payment_Status__c with a value of 'Cleared'. I only want the Recovered_Amt_Ex_VAT__c field of the parent Payment__c to update when the child Payment__c status is updated to 'Cleared'. I have built the below code but it is updating the parent Payment__c regardless of the status.
NOTE: there will be nested child Payment__c scenarios.
//Rolls up the related payment total amounts to parent payment record //
trigger RecoveredAmountOnPayment on Payment__c (after insert, after update, after delete, after undelete) {
Set<ID> setID = new Set<ID>();
List<Payment__c> lstPay = new List<Payment__c>();
if(trigger.isinsert || trigger.isundelete){
for(Payment__c p : trigger.new){
setID.add(p.Replaced_Payment__c);
}
}
else if(trigger.isDelete){
for(Payment__c p : trigger.old){
setID.add(p.Replaced_Payment__c);
}
}
else if(trigger.isUpdate){
for(Payment__c p : trigger.new){
if(p.Replaced_Payment__c != null){
if(trigger.oldmap.get(p.id).Replaced_Payment__c != p.Replaced_Payment__c){
setID.add(p.Replaced_Payment__c);
}
}
setID.add(trigger.oldmap.get(p.id).Replaced_Payment__c);
}
}
if(setid.size() > 0){
lstPay = [Select id,Recovered_Amt_Ex_VAT__c ,(Select id,Payment_Amount__c from Replaced__r) from Payment__c where id IN : setID];
}
for(Payment__c pay : lstPay){
Decimal val = 0;
for(Payment__c rep : pay.Replaced__r){
val += rep.Payment_Amount__c;
}
pay.Recovered_Amt_Ex_VAT__c = val;
}
update lstPay;
}
-
- Nevin O'Regan 3
- March 03, 2020
- Like
- 0
- Continue reading or reply
Validation Rule is causing problems with my Trigger
Hi guys,
I have created a validation rule to make a date field mandatory on a custom Payment__c object when certain values in a picklist are selected. When I activate the rule, it causes issues on records which have a lookup field populated. Below is my trigger. Can anyone see where I am going wrong?
//Rolls up the related payment total amounts to parent payment record //
trigger SumOfReplacedValue on Payment__c (after insert, after update, after delete, after undelete) {
Set<ID> setID = new Set<ID>();
List<Payment__c> lstPay = new List<Payment__c>();
if(trigger.isinsert || trigger.isundelete){
for(Payment__c p : trigger.new){
setID.add(p.Replaced_Payment__c);
}
}
else if(trigger.isDelete){
for(Payment__c p : trigger.old){
setID.add(p.Replaced_Payment__c);
}
}
else if(trigger.isUpdate){
for(Payment__c p : trigger.new){
if(p.Replaced_Payment__c != null){
if(trigger.oldmap.get(p.id).Replaced_Payment__c != p.Replaced_Payment__c){
setID.add(p.Replaced_Payment__c);
}
}
setID.add(trigger.oldmap.get(p.id).Replaced_Payment__c);
}
}
if(setid.size() > 0){
lstPay = [Select id,Replaced_With__c,(Select id,Payment_Amount__c from Replaced__r) from Payment__c where id IN : setID];
}
for(Payment__c pay : lstPay){
Decimal val = 0;
for(Payment__c rep : pay.Replaced__r){
val += rep.Payment_Amount__c;
}
pay.Replaced_With__c = val;
}
update lstPay;
}
I have created a validation rule to make a date field mandatory on a custom Payment__c object when certain values in a picklist are selected. When I activate the rule, it causes issues on records which have a lookup field populated. Below is my trigger. Can anyone see where I am going wrong?
//Rolls up the related payment total amounts to parent payment record //
trigger SumOfReplacedValue on Payment__c (after insert, after update, after delete, after undelete) {
Set<ID> setID = new Set<ID>();
List<Payment__c> lstPay = new List<Payment__c>();
if(trigger.isinsert || trigger.isundelete){
for(Payment__c p : trigger.new){
setID.add(p.Replaced_Payment__c);
}
}
else if(trigger.isDelete){
for(Payment__c p : trigger.old){
setID.add(p.Replaced_Payment__c);
}
}
else if(trigger.isUpdate){
for(Payment__c p : trigger.new){
if(p.Replaced_Payment__c != null){
if(trigger.oldmap.get(p.id).Replaced_Payment__c != p.Replaced_Payment__c){
setID.add(p.Replaced_Payment__c);
}
}
setID.add(trigger.oldmap.get(p.id).Replaced_Payment__c);
}
}
if(setid.size() > 0){
lstPay = [Select id,Replaced_With__c,(Select id,Payment_Amount__c from Replaced__r) from Payment__c where id IN : setID];
}
for(Payment__c pay : lstPay){
Decimal val = 0;
for(Payment__c rep : pay.Replaced__r){
val += rep.Payment_Amount__c;
}
pay.Replaced_With__c = val;
}
update lstPay;
}
-
- Nevin O'Regan 3
- February 19, 2020
- Like
- 0
- Continue reading or reply
Can I add a Quick Action to the Home Screen?
Hi guys,
My users would like to be able to create Accounts from the Home Page. I have created a simple custom button component which I have added to the page but I am unable to get the a working syntax for controller.
Has anyone configured something similar in the past?
My users would like to be able to create Accounts from the Home Page. I have created a simple custom button component which I have added to the page but I am unable to get the a working syntax for controller.
Has anyone configured something similar in the past?
-
- Nevin O'Regan 3
- February 17, 2020
- Like
- 0
- Continue reading or reply
Trigger to sum a value from child to parent object when object had parent child relationship to itself
Hi guys,
I have a custom object called Payment__c, which has a lookup field to itself. I have a custom field called Replaced_Amount__c which I want to sum up the total amount of related payment records. I think the only way of doing this is through a trigger.
I have seen a lot of answers in the community on how to achieve a similar requirement but I haven't seen one where the object has a lookup to itself.
Could anyway help me with this?
I have a custom object called Payment__c, which has a lookup field to itself. I have a custom field called Replaced_Amount__c which I want to sum up the total amount of related payment records. I think the only way of doing this is through a trigger.
I have seen a lot of answers in the community on how to achieve a similar requirement but I haven't seen one where the object has a lookup to itself.
Could anyway help me with this?
-
- Nevin O'Regan 3
- January 05, 2020
- Like
- 0
- Continue reading or reply
Auto Create Custom Schedule Record
Hi guys,
I have a custom object called Year__c which related to the Lease. I have created a related child object called Year_Schedule__c. On the Year__c object there is a Start_Date__c, End_Date__c field, No_Of_Installments__c and Amount__c field.
I'm trying to get this to behave very similar to the standar ScheduleLineItem.
When a user creates a Year__c record I'd like Year_Schedule__c records to automatically create to capture each month within the Start_Date__c and End_Date__c of the parent Year__c record. I have started this out with the below trigger which is creating the record for me but it is not creating a Year_Schedule__c for each month, it is only creating one Year_Schedule__c record.
trigger CreateSchedulesOnYear on Year__c (after insert, after update){
if(Trigger.isInsert){
List<Year_Schedule__c> ylst = new List <Year_Schedule__c>();
for(Year__c yr : trigger.new){
Year_Schedule__c ys = new Year_Schedule__c(
Year__c=yr.Id,
Start_Date__c=yr.Start_Date__c ,
Revenue__c=yr.Dynamic_Amount__c,
End_Date__c=yr.End_Date__c);
ylst.add(ys);
}
insert ylst;
}
}
I have a custom object called Year__c which related to the Lease. I have created a related child object called Year_Schedule__c. On the Year__c object there is a Start_Date__c, End_Date__c field, No_Of_Installments__c and Amount__c field.
I'm trying to get this to behave very similar to the standar ScheduleLineItem.
When a user creates a Year__c record I'd like Year_Schedule__c records to automatically create to capture each month within the Start_Date__c and End_Date__c of the parent Year__c record. I have started this out with the below trigger which is creating the record for me but it is not creating a Year_Schedule__c for each month, it is only creating one Year_Schedule__c record.
trigger CreateSchedulesOnYear on Year__c (after insert, after update){
if(Trigger.isInsert){
List<Year_Schedule__c> ylst = new List <Year_Schedule__c>();
for(Year__c yr : trigger.new){
Year_Schedule__c ys = new Year_Schedule__c(
Year__c=yr.Id,
Start_Date__c=yr.Start_Date__c ,
Revenue__c=yr.Dynamic_Amount__c,
End_Date__c=yr.End_Date__c);
ylst.add(ys);
}
insert ylst;
}
}
-
- Nevin O'Regan 3
- December 13, 2019
- Like
- 0
- Continue reading or reply
Trigger to update lookup field on Product object
Hi guys,
I have a custom object Target__c that is a parent object of Product2. When a new Target__c record is created I want to automatically update the Target__c lookup field on the Product2 object with the latest Target__c record. I have tried the below trigger but I'm running into an Error: duplicate value found: <unknown> duplicates value on record with id: <unknown>
trigger MapTargetsToWarehouse on Targets__c (after insert) {
for(Targets__c target : Trigger.new) {
Product2[] products = [SELECT Id, Target__c FROM Product2];
if (products.size() > 0) {
Product2 product = products[0];
product.Target__c = target.Id;
update product;
}
}
}
I have a custom object Target__c that is a parent object of Product2. When a new Target__c record is created I want to automatically update the Target__c lookup field on the Product2 object with the latest Target__c record. I have tried the below trigger but I'm running into an Error: duplicate value found: <unknown> duplicates value on record with id: <unknown>
trigger MapTargetsToWarehouse on Targets__c (after insert) {
for(Targets__c target : Trigger.new) {
Product2[] products = [SELECT Id, Target__c FROM Product2];
if (products.size() > 0) {
Product2 product = products[0];
product.Target__c = target.Id;
update product;
}
}
}
-
- Nevin O'Regan 3
- December 12, 2019
- Like
- 0
- Continue reading or reply
Autolaunch Flow To Update Lookup Field
Hi guys,
I'm looking to build an Autolaunch Flow which will update a lookup field in the OpportunityLineItemsSchedule object when a field has been update on another object.
I have created a custom object Pronto__c which is a placeholder for inbound data from an external database. I have a custom field on this object called LineItemScheduleId__c. The data coming from the external database also includes the recordId of the OpportunityLineItemSchedule record. Once the LineItemScheduleId__c is updated I want the Pronto__c record to link the the correct OpportunityLineItemSchedule record.
Can anyone guide me with the correct steps I need to take to get this to work using Flow and Process Builder?
I'm looking to build an Autolaunch Flow which will update a lookup field in the OpportunityLineItemsSchedule object when a field has been update on another object.
I have created a custom object Pronto__c which is a placeholder for inbound data from an external database. I have a custom field on this object called LineItemScheduleId__c. The data coming from the external database also includes the recordId of the OpportunityLineItemSchedule record. Once the LineItemScheduleId__c is updated I want the Pronto__c record to link the the correct OpportunityLineItemSchedule record.
Can anyone guide me with the correct steps I need to take to get this to work using Flow and Process Builder?
-
- Nevin O'Regan 3
- November 12, 2019
- Like
- 0
- Continue reading or reply
Flow Not Working After Deploying From Sandbox To Production
Hi guys,
I created an AutoLaunch flow in my sandbox, along with the Process Builder. It works perfectly in the sandbox but when I deploy it, it doesn't work.
I have activated both the Flow and the Process Builder.
Anyone any ideas?
I created an AutoLaunch flow in my sandbox, along with the Process Builder. It works perfectly in the sandbox but when I deploy it, it doesn't work.
I have activated both the Flow and the Process Builder.
Anyone any ideas?
-
- Nevin O'Regan 3
- November 12, 2019
- Like
- 0
- Continue reading or reply
Custom Lightning Button Help
Hi guys,
I'm looking to try and build a custom button which creates a new record and also update a value in another record.
The object in question is a custom object called Payment. The purpose of this button is to allow users replace a payment with another payment. So if a user clicks on this button from within a payment record they will input the field values of the new payment record and the status value of the payment record from which the action was triggered will update to 'Replaced'.
Is this possible through Quick Actions or Buttons and could anyone help me with it?
I'm looking to try and build a custom button which creates a new record and also update a value in another record.
The object in question is a custom object called Payment. The purpose of this button is to allow users replace a payment with another payment. So if a user clicks on this button from within a payment record they will input the field values of the new payment record and the status value of the payment record from which the action was triggered will update to 'Replaced'.
Is this possible through Quick Actions or Buttons and could anyone help me with it?
-
- Nevin O'Regan 3
- November 10, 2019
- Like
- 0
- Continue reading or reply
Trigger that links two records when custom Id field is updated
Hi guys,
I have created a custom object which is being updated with data from and external system. Data is being pulled from the OpportunityLineItemSchedule object to the external system, which then returns the Sales Order number back into the related OppLineItemSch record in Salesforce
The custom object is simply called Pronto__c. I have also created a custom field on this object called OppLineItemSchId__c which is the Id of the related OppLineItemSch record. I also have a lookup field on the OppLineItemSchedule object which looksup Pronto__c.
What I am trying to do is create the relationship between the Pronto__c record and the OpportunityLineItemSchedule record once the Pronto.LineItemScheduleId__c field matches the OpportunityLineItemSchedule.Id field.
I have created a custom object which is being updated with data from and external system. Data is being pulled from the OpportunityLineItemSchedule object to the external system, which then returns the Sales Order number back into the related OppLineItemSch record in Salesforce
The custom object is simply called Pronto__c. I have also created a custom field on this object called OppLineItemSchId__c which is the Id of the related OppLineItemSch record. I also have a lookup field on the OppLineItemSchedule object which looksup Pronto__c.
What I am trying to do is create the relationship between the Pronto__c record and the OpportunityLineItemSchedule record once the Pronto.LineItemScheduleId__c field matches the OpportunityLineItemSchedule.Id field.
-
- Nevin O'Regan 3
- November 07, 2019
- Like
- 0
- Continue reading or reply
Trigger That Creates Related Records Based On A Picklist Field
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?
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?
-
- Nevin O'Regan 3
- October 16, 2019
- Like
- 0
- Continue reading or reply
Field is not updating to a blank value if I delete related OpportintyLineItemSchedule record
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;
}
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;
}
-
- Nevin O'Regan 3
- August 20, 2019
- Like
- 0
- Continue reading or reply
Help creating a test class for a trigger.
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;
}
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;
}
-
- Nevin O'Regan 3
- August 18, 2019
- Like
- 0
- Continue reading or reply
Update Field Values In Parent Object
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;
}
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;
}
-
- Nevin O'Regan 3
- August 15, 2019
- Like
- 0
- Continue reading or reply
Method does not exist or incorrect signature: void put(Id, Decimal) from the type Map<Id,Integer>
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;
}
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;
}
-
- Nevin O'Regan 3
- August 15, 2019
- Like
- 0
- Continue reading or reply
Trigger To Update Field On OpportunityLineItem From OpportunityLineItemSchedule
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 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?
-
- Nevin O'Regan 3
- August 08, 2019
- Like
- 0
- Continue reading or reply
SOQL Query to return matching fields
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?
-
- Nevin O'Regan 3
- August 07, 2019
- Like
- 0
- Continue reading or reply
Update Approval Status Field based on OpportunityLineItem Sales Price
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?
Can anyone give me some help with wrighting a trigger for this?
-
- Nevin O'Regan 3
- August 05, 2019
- Like
- 0
- Continue reading or reply
Custom Buttons On Custom Components
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?
-
- Nevin O'Regan 3
- February 07, 2019
- Like
- 1
- Continue reading or reply
Big Object Limits
If I create a Big Object and then delete it is that counted towards the 100 big object limit?
-
- Nevin O'Regan 3
- October 16, 2018
- Like
- 1
- Continue reading or reply
Error When Adding A Custom Component To Community Page
Hi guys,
I've created a custom screen flow and I want to add it to a community page, launched from a custom button on the Homepage.
The flow guides users through creating a case. I am getting the following error when I add the component to the page: "Action failed: c:CustomCaseCommunityComponent$controller$init [flowData is not defined]"
This is my component.
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,forceCommunity:availableForAllPageTypes,force:hasRecordId,force:lightningQuickActionWithoutHeader" access="global">
<aura:handler name="init" value="{!this}" action="{!c.init}"/>
<lightning:flow aura:id="flowData"/>
</aura:component>
({
init : function (component) {
var flow = component.find(flowData);
flow.startFlow(CaseFlow);
},
})
I've created a custom screen flow and I want to add it to a community page, launched from a custom button on the Homepage.
The flow guides users through creating a case. I am getting the following error when I add the component to the page: "Action failed: c:CustomCaseCommunityComponent$controller$init [flowData is not defined]"
This is my component.
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,forceCommunity:availableForAllPageTypes,force:hasRecordId,force:lightningQuickActionWithoutHeader" access="global">
<aura:handler name="init" value="{!this}" action="{!c.init}"/>
<lightning:flow aura:id="flowData"/>
</aura:component>
({
init : function (component) {
var flow = component.find(flowData);
flow.startFlow(CaseFlow);
},
})
- Nevin O'Regan 3
- April 06, 2020
- Like
- 0
- Continue reading or reply
I want a picklist field to move to the next value in a flow
Hi guys,
I have a custom object called Year__c whis has a picklist field called Period__c which has values 1 - 10. I have built a screen flow which includes the creation of a Year__c object.
Each time a new Year__c record is created I want the Period__c to automatically update with the next picklist value.
How can I do this in a flow?
I have a custom object called Year__c whis has a picklist field called Period__c which has values 1 - 10. I have built a screen flow which includes the creation of a Year__c object.
Each time a new Year__c record is created I want the Period__c to automatically update with the next picklist value.
How can I do this in a flow?
- Nevin O'Regan 3
- March 24, 2020
- Like
- 0
- Continue reading or reply
Help With A Roll Up Trigger
Hi guys,
I'm looking for some help with a trigger that I have built on a custom object which has a lookup field to itself.
I object Payment__c has a custom picklist field Payment_Status__c with a value of 'Cleared'. I only want the Recovered_Amt_Ex_VAT__c field of the parent Payment__c to update when the child Payment__c status is updated to 'Cleared'. I have built the below code but it is updating the parent Payment__c regardless of the status.
NOTE: there will be nested child Payment__c scenarios.
//Rolls up the related payment total amounts to parent payment record //
trigger RecoveredAmountOnPayment on Payment__c (after insert, after update, after delete, after undelete) {
Set<ID> setID = new Set<ID>();
List<Payment__c> lstPay = new List<Payment__c>();
if(trigger.isinsert || trigger.isundelete){
for(Payment__c p : trigger.new){
setID.add(p.Replaced_Payment__c);
}
}
else if(trigger.isDelete){
for(Payment__c p : trigger.old){
setID.add(p.Replaced_Payment__c);
}
}
else if(trigger.isUpdate){
for(Payment__c p : trigger.new){
if(p.Replaced_Payment__c != null){
if(trigger.oldmap.get(p.id).Replaced_Payment__c != p.Replaced_Payment__c){
setID.add(p.Replaced_Payment__c);
}
}
setID.add(trigger.oldmap.get(p.id).Replaced_Payment__c);
}
}
if(setid.size() > 0){
lstPay = [Select id,Recovered_Amt_Ex_VAT__c ,(Select id,Payment_Amount__c from Replaced__r) from Payment__c where id IN : setID];
}
for(Payment__c pay : lstPay){
Decimal val = 0;
for(Payment__c rep : pay.Replaced__r){
val += rep.Payment_Amount__c;
}
pay.Recovered_Amt_Ex_VAT__c = val;
}
update lstPay;
}
I'm looking for some help with a trigger that I have built on a custom object which has a lookup field to itself.
I object Payment__c has a custom picklist field Payment_Status__c with a value of 'Cleared'. I only want the Recovered_Amt_Ex_VAT__c field of the parent Payment__c to update when the child Payment__c status is updated to 'Cleared'. I have built the below code but it is updating the parent Payment__c regardless of the status.
NOTE: there will be nested child Payment__c scenarios.
//Rolls up the related payment total amounts to parent payment record //
trigger RecoveredAmountOnPayment on Payment__c (after insert, after update, after delete, after undelete) {
Set<ID> setID = new Set<ID>();
List<Payment__c> lstPay = new List<Payment__c>();
if(trigger.isinsert || trigger.isundelete){
for(Payment__c p : trigger.new){
setID.add(p.Replaced_Payment__c);
}
}
else if(trigger.isDelete){
for(Payment__c p : trigger.old){
setID.add(p.Replaced_Payment__c);
}
}
else if(trigger.isUpdate){
for(Payment__c p : trigger.new){
if(p.Replaced_Payment__c != null){
if(trigger.oldmap.get(p.id).Replaced_Payment__c != p.Replaced_Payment__c){
setID.add(p.Replaced_Payment__c);
}
}
setID.add(trigger.oldmap.get(p.id).Replaced_Payment__c);
}
}
if(setid.size() > 0){
lstPay = [Select id,Recovered_Amt_Ex_VAT__c ,(Select id,Payment_Amount__c from Replaced__r) from Payment__c where id IN : setID];
}
for(Payment__c pay : lstPay){
Decimal val = 0;
for(Payment__c rep : pay.Replaced__r){
val += rep.Payment_Amount__c;
}
pay.Recovered_Amt_Ex_VAT__c = val;
}
update lstPay;
}
- Nevin O'Regan 3
- March 03, 2020
- Like
- 0
- Continue reading or reply
Can I add a Quick Action to the Home Screen?
Hi guys,
My users would like to be able to create Accounts from the Home Page. I have created a simple custom button component which I have added to the page but I am unable to get the a working syntax for controller.
Has anyone configured something similar in the past?
My users would like to be able to create Accounts from the Home Page. I have created a simple custom button component which I have added to the page but I am unable to get the a working syntax for controller.
Has anyone configured something similar in the past?
- Nevin O'Regan 3
- February 17, 2020
- Like
- 0
- Continue reading or reply
Trigger to sum a value from child to parent object when object had parent child relationship to itself
Hi guys,
I have a custom object called Payment__c, which has a lookup field to itself. I have a custom field called Replaced_Amount__c which I want to sum up the total amount of related payment records. I think the only way of doing this is through a trigger.
I have seen a lot of answers in the community on how to achieve a similar requirement but I haven't seen one where the object has a lookup to itself.
Could anyway help me with this?
I have a custom object called Payment__c, which has a lookup field to itself. I have a custom field called Replaced_Amount__c which I want to sum up the total amount of related payment records. I think the only way of doing this is through a trigger.
I have seen a lot of answers in the community on how to achieve a similar requirement but I haven't seen one where the object has a lookup to itself.
Could anyway help me with this?
- Nevin O'Regan 3
- January 05, 2020
- Like
- 0
- Continue reading or reply
Autolaunch Flow To Update Lookup Field
Hi guys,
I'm looking to build an Autolaunch Flow which will update a lookup field in the OpportunityLineItemsSchedule object when a field has been update on another object.
I have created a custom object Pronto__c which is a placeholder for inbound data from an external database. I have a custom field on this object called LineItemScheduleId__c. The data coming from the external database also includes the recordId of the OpportunityLineItemSchedule record. Once the LineItemScheduleId__c is updated I want the Pronto__c record to link the the correct OpportunityLineItemSchedule record.
Can anyone guide me with the correct steps I need to take to get this to work using Flow and Process Builder?
I'm looking to build an Autolaunch Flow which will update a lookup field in the OpportunityLineItemsSchedule object when a field has been update on another object.
I have created a custom object Pronto__c which is a placeholder for inbound data from an external database. I have a custom field on this object called LineItemScheduleId__c. The data coming from the external database also includes the recordId of the OpportunityLineItemSchedule record. Once the LineItemScheduleId__c is updated I want the Pronto__c record to link the the correct OpportunityLineItemSchedule record.
Can anyone guide me with the correct steps I need to take to get this to work using Flow and Process Builder?
- Nevin O'Regan 3
- November 12, 2019
- Like
- 0
- Continue reading or reply
Flow Not Working After Deploying From Sandbox To Production
Hi guys,
I created an AutoLaunch flow in my sandbox, along with the Process Builder. It works perfectly in the sandbox but when I deploy it, it doesn't work.
I have activated both the Flow and the Process Builder.
Anyone any ideas?
I created an AutoLaunch flow in my sandbox, along with the Process Builder. It works perfectly in the sandbox but when I deploy it, it doesn't work.
I have activated both the Flow and the Process Builder.
Anyone any ideas?
- Nevin O'Regan 3
- November 12, 2019
- Like
- 0
- Continue reading or reply
Custom Lightning Button Help
Hi guys,
I'm looking to try and build a custom button which creates a new record and also update a value in another record.
The object in question is a custom object called Payment. The purpose of this button is to allow users replace a payment with another payment. So if a user clicks on this button from within a payment record they will input the field values of the new payment record and the status value of the payment record from which the action was triggered will update to 'Replaced'.
Is this possible through Quick Actions or Buttons and could anyone help me with it?
I'm looking to try and build a custom button which creates a new record and also update a value in another record.
The object in question is a custom object called Payment. The purpose of this button is to allow users replace a payment with another payment. So if a user clicks on this button from within a payment record they will input the field values of the new payment record and the status value of the payment record from which the action was triggered will update to 'Replaced'.
Is this possible through Quick Actions or Buttons and could anyone help me with it?
- Nevin O'Regan 3
- November 10, 2019
- Like
- 0
- Continue reading or reply
Trigger That Creates Related Records Based On A Picklist Field
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?
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?
- Nevin O'Regan 3
- October 16, 2019
- Like
- 0
- Continue reading or reply
Update Field Values In Parent Object
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;
}
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;
}
- Nevin O'Regan 3
- August 15, 2019
- Like
- 0
- Continue reading or reply