You need to sign in to do that
Don't have an account?
dandamudi
validation rule to stop multiple quotes won on opportunity
Hi,
I have opp standard obj and quote is custom(child) object , validation should throw when i change the quote status filed to won if that opportunity had already won Quote.
that means opportunity should have multiple quotes but should not multiple Won Quotes.
I have opp standard obj and quote is custom(child) object , validation should throw when i change the quote status filed to won if that opportunity had already won Quote.
that means opportunity should have multiple quotes but should not multiple Won Quotes.
You can achieve this through a trigger. Please find the code below.
Since I don't have the exact name of custom object quote and fields. I made them up. Please change them as per your need.
Sorry for late reply , i don't understand your logic at line no 14, how did you use master object as sub query, i ran your querry it throws error
in my case Quote as custom object with opportunity field is Master detail type
You mentioned Quote is a custom child object. I am not sure why you are not using Standard Object Quote. Keeping your perspective of Quote being a custom object, I treated it as Quote__c and when it reference in the Sub Query we use the Child Relationship Name which normally ends up with Quotes__r. You can find that name by click the Quote Master/Detail field.
You haven't shared the error so I am not sure what exactly issue you are getting. Can you please share the exact error you are getting.
below error i got
(Select Id From Quote__r WHERE Quote_Status__c =
^
ERROR at Row:2:Column:48
Didn't understand relationship 'Quote__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
You can also look by going on the Fields of the Quote Object and click Edit on the Opportunity field and take a look of the Child Relationship Name.
iMaster detail Relationship from Quote to Opportunity
I noticed you are changing the Quotes__r to Quote__r. Therefore you are getting error. Can you use the way I am using and let me know if you are still getting issues.
i used below same code still i got same error
(Select Id From Quotes__r WHERE Quote_Status__c
^
ERROR at Row:2:Column:48
Didn't understand relationship 'Quotes__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
You can simplify your code with this
ex: opp doesn't have won quotes, i tried to move one Quote to Won, then Error fires.
i implemented the above logic before update.