You need to sign in to do that
Don't have an account?
alxhdez
This is what im trying
Logic problem, it is possible? Add more quotelineitems if it has more than 1 on quantity
- Hello Guys.
- My method does not work correctly.
- What it does is call another method inside a loop, the functionality is to take each quotelineitem from the quote until it finishes collecting all the quotelineitems there are. (The method takes one quotelineitem at a time, that's why the loop).
- My problem arises when I want to add an extra quotelineitem if its quantity is greater than one, also concatenating a number 1-2-3-...-etc , depending on the quantity in the quoteline item.
- My first code works fine, skipping the quantity part inside the quotelineitem The second code is when I try to add an extra quotelineitem depending on the amount, which is where I need your help guys.
- The problem specific is the first code
- Thank you, good day :)
public static String SendEpics(String oppId, String idproject){ Quote quotes = [SELECT Id, Name FROM Quote WHERE OpportunityId =: oppId AND IsSyncing=true LIMIT 1]; List<QuoteLineItem> qlitems = [SELECT Id, Product2.Name, Product2.Description, Quantity FROM QuoteLineItem WHERE QuoteId =: quotes.Id]; //Example in the quoteline items list //ProductA, ProductB, ProductC //On product C, on quantity field I have 3, so I need to extend the quotelineitems like: //ProductA, ProductB, ProductC1, ProductC2, ProductC3 for(Quotelineitem qli :qlitems){ //What is doing? //Executing the method by passing it one quotelineitem per loop until all quotelineitems are finished postEpicIssuesIndividual(oppId, idproject, qli); //Here is calling one method that need one quotelineitem per call, I cant do it with a list //What should do now? //More quotelineitems should be added if the number in them is greater than 1. //Example: If the quantity of one of the quotelineitems is 2, //I have to add 2 quotelineitems instead of 1, concatenating a number. example; quotelineItemExample1, quotelineItemExample2 } return null; }
This is what im trying
public static String SendEpics(String oppId, String idproject){ Quote quotes = [SELECT Id, Name FROM Quote WHERE OpportunityId =: oppId AND IsSyncing=true LIMIT 1]; List<QuoteLineItem> qlitems = [SELECT Id, Product2.Name, Product2.Description, Quantity FROM QuoteLineItem WHERE QuoteId =: quotes.Id]; for(Quotelineitem qli :qlitems){ if(qli.Quantity > 1){ for(Integer i = 0; i > qli.Quantity; i++){ qli.Product2.Name = qli.Product2.Name + i; qli.Product2.Description = qli.Product2.Description; qlitems.add(qli); } } postEpicIssuesIndividual(oppId, idproject, qli); } return null; }
I see you also reached out on https://salesforce.stackexchange.com/questions/374840/logic-problem-it-is-possible-add-more-quotelineitems-if-it-has-more-than-1-on
Does the answer provided in above link help? If so, please consider closing this thread marking answer as best so it can help others too.Thanks