You need to sign in to do that
Don't have an account?
hi am getting this error to my mail help me to get rid of this error
Developer script exception from Nicomatic : quotepotential : quotepotential: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0Q90000005Q9RWEA0; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: [] Trigger.quotepotential: line 17, column 1
caused by: System.DmlException: Update failed. First exception on row 0 with id a0Q90000005Q9RWEA0; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: []
Trigger.quotepotential: line 17, column 1
this is my Trigger:
trigger quotepotential on Quote_Line_Item__c (after insert,after update) { Set<Id> quoteIds = new Set<Id>(); List<Quote__c> quotes = new List<Quote__c>(); for(Quote_Line_Item__c record: Trigger.new) { if (record.Quote1__c != null){ quoteIds.add(record.Quote1__c); } } for(AggregateResult ar:[SELECT Quote1__c , SUM(Max_Batch__c)sumMax FROM Quote_Line_Item__c WHERE Quote1__c IN :quoteIds GROUP BY Quote1__c]) { Quote__C qu=new quote__c(); qu.id=(Id)ar.get('Quote1__c'); qu.Potential__c=(Decimal)ar.get('sumMax'); quotes.add(qu);
} if(quotes.isempty() == false) { update quotes; } }
we have one more button in quote email template at the time click this button i am getting exception to my mail.
the function of quote email template it will send the quote pdf into email which sending to other user
Hi,
I have modified your trigger below. Could you please try this:-
Let me know if you still see any problem with it.
Happy to help you!
Error: Compile Error: unexpected token: 'Map' at line 11 column 33
I am getting error like this
trigger quotepotential on Quote_Line_Item__c (after insert,after update) {
Set<Id> quoteIds = new Set<Id>();
List<Quote__c> quotes = new List<Quote__c>();
for(Quote_Line_Item__c record: Trigger.new) {
if (record.Quote1__c != null){
quoteIds.add(record.Quote1__c);
}
}
Map<Id, Quote__c> mapQuote = Map<Id, Quote__c>([Select Id, Potential__c from Quote__c Where Id in: quoteIds]);
for(AggregateResult ar:[SELECT Quote1__c , SUM(Max_Batch__c)sumMax FROM Quote_Line_Item__c WHERE Quote1__c IN :quoteIds GROUP BY Quote1__c]) {
if(mapQuote.containsKey(Quote1__c)){
Quote__C qu = mapQuote.get(Quote1__c);
qu.Potential__c=(Decimal)ar.get('sumMax');
quotes.add(qu);
}
}
if(quotes.isempty() == false)
{
update quotes;
}
}
Error: Compile Error: unexpected token: 'Map' at line 3 column 29
Hi,
My mistake, missed new keyword. Could you please try below:-
Let me know if you see any other problem.
hi i have already kept that new before only
still i am facing the error it is not taking Quote!__C
Variable does not exist: Quote1__c
Hi,
Another amendment. Could you please try below:-
Please let me know if you still see any problem.
hi thank you for your program it is executing fine .still i am getting execution mails which i posted first unable to LOCK_ROW
the same issue.could you try another possible way to try it out.
this program is fine .thankyou for ur help.
can you help so that i cannot get the exception mails.
Hi,
Is this error mails coming for same trigger or for some other code?
Ya the same Trigger
Hi,
Can you please confirm if Quote records are getting updated as per your requirement?
trigger is working fine .i got the replies as try with future method in the triiger
Hi,
Could you please paste the trigger, where you want to call the future method.
ya surely i will paste it .i a m on that work only .you need the old trigger which is not modified or the new one
Hi,
I need both the triggers, one which is working fine and the one which have problem.
I will send you soon
hi this is the old trigger i am sending you
trigger quotepotential on Quote_Line_Item__c (after insert,after update) {
Set<Id> quoteIds = new Set<Id>();
List<Quote__c> quotes = new List<Quote__c>();
for(Quote_Line_Item__c record: Trigger.new) {
if (record.Quote1__c != null){
quoteIds.add(record.Quote1__c);
}
}
for(AggregateResult ar:[SELECT Quote1__c , SUM(Max_Batch__c)sumMax FROM Quote_Line_Item__c WHERE Quote1__c IN :quoteIds GROUP BY Quote1__c]) {
Quote__C qu=new quote__c();
qu.id=(Id)ar.get('Quote1__c');
qu.Potential__c=(Decimal)ar.get('sumMax');
quotes.add(qu);
}
if(quotes.isempty() == false)
{
update quotes;
}
}
this was the new trigger with future method but not working
trigger quotepotential on Quote_Line_Item__c (after insert,after update) {
Set<id> uniqueNames=new Set<id>();
for(Quote_Line_Item__c a :Trigger.new) {
if(a.IsFutureContext__c) {
a.IsFutureContext__c = true;
} else {
uniqueNames.add(a.id);
}
}
if(!uniqueNames.isEmpty())
asyncApex.processAccounts(uniqueNames);
}
global class asyncApex {
@future
public static void processAccounts(set<id> id) {
Set<Id> quoteIds = new Set<Id>();
List<Quote__c> quotes = new List<Quote__c>();
for (Quote_line_item__c a : [Select Id, Name, IsFutureContext__c From Quote_line_item__c where ID IN :ID]) {
a.IsFutureContext__c = true;
if (a.Quote1__c != null){
quoteIds.add(a.Quote1__c);
}
for(AggregateResult ar:[SELECT Quote1__c , SUM(Max_Batch__c)sumMax FROM Quote_Line_Item__c WHERE Quote1__c IN :quoteIds GROUP BY Quote1__c]) {
Quote__C qu=new quote__c();
qu.id=(Id)ar.get('Quote1__c');
qu.Potential__c=(Decimal)ar.get('sumMax');
quotes.add(qu);
}
if(quotes.isempty() == false)
{
update quotes;
}
}
}
}
can you correct this one .
Hi,
Keeping your trigger unchanged, could you please try below version of async class:-
Let me know if you still see error.
Happy to help you!
sorry .i am not the value for potential.any different idea
I am not getting the value of potential in this program can any crack this error?