How can we access the value of a field from one object to t

Posted by seema on 06-Mar-2014 01:47

How can we access the value of a field from one object  to the another object.

Suppose I have two objects: Order-line and Item.

Order-line form have fields item and quantity. After saving the record, I want to deduct the quantity used by Order-line to be deducted from total quantity field of Item object.

Can anybody suggest how to implement this.

Posted by Chandrasekhar Gontla on 07-Mar-2014 07:41

Hi,

Please follow the steps below to acheive what you are asking

-> Create 2 objects called Orderline and Item

-> Create a one to many relationship with Item object in Orderline object. Make sure that select all pages for Item look up field in order to show that look up field in Order object pages while creating relationship.

-> Create an integer field called Quantity in orderline object and create an integer field called Total Quantity in Item object.

-> Go to Quantity field definition and click on Validation link and provide following code

if ({!quantity} > {!R92973419.total_quantity})

return "Quantity value should be more than "+{!R92973419.total_quantity}

-> create one formula field called Remaining Quantity in Item object. And, in that formula field, provide following code.

Note: select return type as integer

Note: Formula field is read only which can executed on the top of existing fields

return {!total_quantity} - {!R92973419.quantity};

-> Now, create a record in Orderline object. Create Item object's record using quick create (or select existing item object's record using selector pop up) while creating Orderline's record.

-> Go to Item records list page and observe that 'Remaining Quantity' will give the value that is deducted Quantiy value from Total Quantity.

Please let me know if you have any questions.

All Replies

Posted by Chandrasekhar Gontla on 07-Mar-2014 07:41

Hi,

Please follow the steps below to acheive what you are asking

-> Create 2 objects called Orderline and Item

-> Create a one to many relationship with Item object in Orderline object. Make sure that select all pages for Item look up field in order to show that look up field in Order object pages while creating relationship.

-> Create an integer field called Quantity in orderline object and create an integer field called Total Quantity in Item object.

-> Go to Quantity field definition and click on Validation link and provide following code

if ({!quantity} > {!R92973419.total_quantity})

return "Quantity value should be more than "+{!R92973419.total_quantity}

-> create one formula field called Remaining Quantity in Item object. And, in that formula field, provide following code.

Note: select return type as integer

Note: Formula field is read only which can executed on the top of existing fields

return {!total_quantity} - {!R92973419.quantity};

-> Now, create a record in Orderline object. Create Item object's record using quick create (or select existing item object's record using selector pop up) while creating Orderline's record.

-> Go to Item records list page and observe that 'Remaining Quantity' will give the value that is deducted Quantiy value from Total Quantity.

Please let me know if you have any questions.

Posted by seema on 10-Mar-2014 06:40

Thanks for the reply but when I tried to deduct the quantity from remaining quantity instead of total quantity after first iteration then it failed.  

This thread is closed