How to add Id as a default value to a field when its' model is not the context model

  • 1
  • Question
  • Updated 3 years ago
On the mobile builder I have an object for Orders and a button that creates a new Order and all of the detail required.

I then have a product grid view and a button within this that adds a new "Order Item" record, allows entry of quantity etc and inserts the Product Id as a default field

Inserting the Product Id as a default field value is ok as the button sits within the context of the Product model but I also need to add the Order Id to the Order Item record to ensure that the Order Item is attached to the Order as a child but for the life of me I cant find how to find the Order Id given the button isnt within the Order model context.

I have tried every combination of {{Orders__r.Id}} I can think of and I am not familiar with writing snippets to achieve this?

Is there a simple way as it sounds simple to me )
Photo of David Forder

David Forder

  • 2,144 Points 2k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
David,

I'm not familiar with the relationship between products and orders, but if there is a relationship between them, you should be able to navigate that relationship with merge syntax. Otherwise, you can access the Id of the first row of the Order model with global merge syntax: {{$Model.Order.data.0.Id}}
Photo of David Forder

David Forder

  • 2,144 Points 2k badge 2x thumb
Thanks Matt .. that worked. I had tried merge syntax was had left off the .data .. really appreciate the help!