It turns out that Sugar does not enforce 1:1 relationships, it overwrites them with no warning to the user. (Bug?)
Is my only option for enforcement a custom before-relationship-add logic hook?
Thanks,
Francesca
It turns out that Sugar does not enforce 1:1 relationships, it overwrites them with no warning to the user. (Bug?)
Is my only option for enforcement a custom before-relationship-add logic hook?
Thanks,
Francesca
Hi Francesca Shiekh,
The first answer comes to my mind is the logic hook as you mentioned. However, It would be good to know your use case.
Tevfik Tümer
Sr. Developer Support Engineer
Thank you Tevfik Tümer ,
we have a 1:1 between Quotes and Cases.
Cases are created to let our CS team know that the order is ready to enter.
Our Sales team creates a Case to process an Order in our ERP system for a given a Quote, and attaches the customer PO to the Case, they link the Case to the Quote.
We want to make sure that there is only one Case per Quote and only one Quote per Case, and if someone tries to enter a second Case for that same quote, or a second Quote for the same Case, we want to stop them from doing so and alert them to the fact that there is already a Case for that Quote.
I added a 1:1 Cases-Quotes.
Example of the non enforcement:
CaseA, relate to QuoteA => The related CaseA shows on the QuoteA, the related QuoteA shows on the CaseA
CaseB relate to QuoteA => CaseB shows QuoteA, QuoteA shows CaseB, CaseA has lost the relationship and is left without a related Quote and there was no warning that the relationship between CaseA and QuoteA was being removed.
To me, that's a big problem as other Sugar customers in similar scenarios may be losing data.
The logical expectation of a 1:1 is that it would be enforced by the code with a warning that proceeding will destroy the previously exising relationship.
Thank you,
Francesca
Thank you Tevfik Tümer ,
we have a 1:1 between Quotes and Cases.
Cases are created to let our CS team know that the order is ready to enter.
Our Sales team creates a Case to process an Order in our ERP system for a given a Quote, and attaches the customer PO to the Case, they link the Case to the Quote.
We want to make sure that there is only one Case per Quote and only one Quote per Case, and if someone tries to enter a second Case for that same quote, or a second Quote for the same Case, we want to stop them from doing so and alert them to the fact that there is already a Case for that Quote.
I added a 1:1 Cases-Quotes.
Example of the non enforcement:
CaseA, relate to QuoteA => The related CaseA shows on the QuoteA, the related QuoteA shows on the CaseA
CaseB relate to QuoteA => CaseB shows QuoteA, QuoteA shows CaseB, CaseA has lost the relationship and is left without a related Quote and there was no warning that the relationship between CaseA and QuoteA was being removed.
To me, that's a big problem as other Sugar customers in similar scenarios may be losing data.
The logical expectation of a 1:1 is that it would be enforced by the code with a warning that proceeding will destroy the previously exising relationship.
Thank you,
Francesca
Hi Francesca Shiekh ,
I think the current behavior is valid as there are reasons for changing a 1:1 relationship and there also isn't a configuration to say "this relationship should only be changeable from one side and not the other".
With that said, you can make this enforceable with a combination of SugarLogic and SugarBPM with the following steps:
ifElse( and( equal( related( $cases_quotes_1, "description" ), "Case" ), equal( $quote_saved_c, 0 ) ), "", "Valid" )
and( not( equal( related( $cases_quotes_1, "name" ), "" ) ), equal( related( $cases_quotes_1, "case_related_c" ), "Yes" ), equal( $quote_saved_c, 0 ) )
Once that is done, the case record will show whether it's a valid quote:
Or an invalid quote:
I hope this helps!
Chris
EDIT: I realized my initial solution would only work for the first save of the case with a quote. Going back to that case would have resulted in a failure in the validation check when trying to save another update. I added steps 3 & 4 and updated the case formulas to account for that oversight.
Thanks for the details.
Honestly, I would consider this problem from different aspects.
If the main concern is preventing this from happening in the UI, then I would work on the related field.
Users are probably clicking the related field and selecting from the list view. You can force that list view to avoid listing the quotes that have cases. Using filters should also affect typeahead queries.
As a preventive measure, you could throw an exception before saving if the fetched row already has that field. Since they are 1-1, you should be able to check that as a field rather than a relationship.
Tevfik Tümer
Sr. Developer Support Engineer