Update a field on a Parent Record from within a Table of Child Records

I have a table of Approval records (we’re using the Advanced Approvals managed package), where there could be many for a single Quote Line. Reason being that the users need to be able to action on that particular record…and so that they can see all the Approvals that are required before all the Quote Lines (and thus the whole Quote) are “fully approved”.

However, some of the calculation/updates really should be done at the Quote Line level - such as cost/margin calculations.

What I want to be able to do:

  • Use a Table of Approvals
  • Field on Approval (whether UI-only or a proper field, doesn’t really matter) that is editable by product managers called “Target Margin”
  • When Target Margin is updated/record is saved (the PMs might “mess around” with these numbers on multiple records based on circumstances), update an identical field on the Quote Line
  • On the Quote Line, have a formula field to reverse engineer a “Target Discount”, so that the Sales user can see, “Oh, the PM is advising me to change the discount to 20%”…
  • …because Sales doesn’t see the Approval records in their “working page” (a VF page from CPQ managed package), which is why I need the value to “work its way up” to the Quote Line, so to speak

I found this post from back in 2015, but I’m admittedly not well-versed (read: at all) with javascript, and I’m also not sure how to translate the code to update a field that’s not even on the same model.

Is this possible?

Maybe Show table of approvals. When the user is completing the approval you display a button called “update target margin”. The user clicks that as part of the approval process. This opens a sliding panel displaying the target margin field from the quote line in edit mode. The user edits that field and clicks a button labeled “save” that saves the quote line model and closes the sliding panel. That brings the user back to the approval screen where they finish their approval.

Thank you! I forgot to mention that I had thought of a button - I’ve used concepts like that in the past to set the Id on a singular record to allow for updating, etc…

I’m just crossing my fingers that there’s a way to do it directly in the table, since some of these tables could have quite a lot of records, and if they’re trying to manipulate/play around with 20+ lines, but have to do them all separately as button-open panel-save…eek.

(Doesn’t help that they’re migrating from a completely customized offline tool that allows them to manipulate directly in a table. :frowning: )

Ok - here goes some crazy talk. The 2015 post was before we had as robust a set of actions as we have now. I think we could essentially reproduce that code with our actions. To be fair - I’m totally not sure this would be performant, and I haven’t tested this. But here goes.

  1. Create a UI Only field on your Approvals model.
  2. Create a Model action that triggers on update of that UI Only field in the Approvals model. Sequence should do the following:
  • A: Queries your quote object to the single record associated with the approval
  • B: Updates the related field on the Quote object model - using the UI Only field value.
  • C: Saves the Quote object model.

You probably also want to have an action on query of the Approval model that retrieves values from the quote object and updates the UI Only field on the Approval model. This way your data will populate correctly on page load and re-query.

Let me know if wild science works for you.

Thank you!! I am SO CLOSE.

And I feel like this should not be hard, and I already know this, but…

How do I explicitly define where to get the data from UI field (as you mentioned in bullet B)? Right now, it’s pulling the value of the first Approval record, not the row I’m on. (I know I’m going to kick myself…)

Sorry for the delay @MonicaLorey . What’s in your picture should work. I just tested to make sure that model actions carry the context of the row that triggers them into the actions defined underneath them.

A debug tip and a warning.

Tip: Add a “block UI w message” action that has your field merge syntax. That way you’ll know if you have the data you want to pass into the other model.

Warning: If you have a “Create row” action somewhere above these actions - know that it “captures” context - and so the merge syntaxt for the direct field you think you have in context will not be there.

Its tricky…