You need to sign in to do that
Don't have an account?
Swamy P R N
How to compare two same fields in different objects
Hi Buddies,
I need help on small trigger, that was like i have two objects i.e, Inventory and Order.
Both Order,Inventory having Quantity(Integer),Product(Lookup) fields.
Now whenver order is created i need to compare Order Quantity,product with inventory Quantity,product.
If Order quantity is available i.e, it is smaller than Inventory quantity -->Ok, but
If Order quantity is greater than Inventory quantity, than i need to show a error like " Given quantity is not available for selected Product".
For this how can i compare the fields based on selected product. Plz suggest me. is it by Map?.If yes, plz suggest how to achieve.
I need help on small trigger, that was like i have two objects i.e, Inventory and Order.
Both Order,Inventory having Quantity(Integer),Product(Lookup) fields.
Now whenver order is created i need to compare Order Quantity,product with inventory Quantity,product.
If Order quantity is available i.e, it is smaller than Inventory quantity -->Ok, but
If Order quantity is greater than Inventory quantity, than i need to show a error like " Given quantity is not available for selected Product".
For this how can i compare the fields based on selected product. Plz suggest me. is it by Map?.If yes, plz suggest how to achieve.
Something like this:
Build the map for inventories where key is equals to ID of product and value related Inventory__c:
After that you can compare quantities and add error if needed:
However, logic of trigger should be slightly more complex. You have to be able manage case of couple Orders with the same Product__c value.
I mean i.e. order1.quantity = 5, order2.quantity = 4 and inventory.quantity = 8.
All Answers
you can do this
Something like this:
Build the map for inventories where key is equals to ID of product and value related Inventory__c:
After that you can compare quantities and add error if needed:
However, logic of trigger should be slightly more complex. You have to be able manage case of couple Orders with the same Product__c value.
I mean i.e. order1.quantity = 5, order2.quantity = 4 and inventory.quantity = 8.