You need to sign in to do that
Don't have an account?
Force.platform
can we update field of unrelated object in trigger
I have two objects:
1)EProduct__c with field Quantity__C
2)EOrder__C with field OQuantity__c
my req. is when order get placed Quantity on product should get reduce as per quantity in order
1)EProduct__c with field Quantity__C
2)EOrder__C with field OQuantity__c
my req. is when order get placed Quantity on product should get reduce as per quantity in order
Please provide more details
Thanks
there are two objects:
1)EProduct__c with field Quantity__C
2)EOrder__C with field OQuantity__c and Product__C
there is no any relation between them.
when we create order record with Quantit__C. and also Product__C(text) field on EOrder__C is same as EProduct__c name
then
Quntity on EProduct__c=Quntity on EProduct__c - Quantity on EOrder__c
Retrive the Quantity__c field in the SOQL above. Update the field by deducting the OQuntity__c from it (this will also help you valdiate whether there is enough quantity in the EProduct__c for the EOrder__c to be executed.
Update the EProduct__c record.
for( EOrder__c tempEOrder:Trigger.new)
{
integer quantityEOrder=tempEOrder.OQuantity__c ;
list<EORder__c> temp=[select Product__C from EOrder__C ];
EProduct__c tempproduct= [select id,Quantity__C from EProduct__c where Name=:temp.Product__C];
Integer finalQuantity=tempproduct.Quantity__C-quantityEOrder;
tempproduct.Quantity__C= finalQuantity;
update tempproduct;
}
Thanks
its not updating quantity on EProduct__C object
Use this Code
Check the API name of fields and Objects
And After Saving Record of EOrder__C refresh the EProduct__c object Record
If any issue please let me know. I am happy to solve it .
Thanks.
you can achieve this with process builder and flow