You need to sign in to do that
Don't have an account?
Toby Tarczy
Update a new field on the Order Object
Hi,
I have created a new object called Factory with a field called Factory.name. I would now like to update all the Order records as I have added a lookup field from Order to the Factory Object to add the Factory.name on the order. The filter would be based on the customer name where I would like to run the update script for each customer separately. The upate would be all orders with the name of "Account Name to be added" , (preference would be to include multiple account names), and the Factory Name would = "Wolverhampton". I am not very well versed with DML or SFCD sql , however if someone could kindly provide the statement structure I would be very gratelful.
Many thanks
Toby
I have created a new object called Factory with a field called Factory.name. I would now like to update all the Order records as I have added a lookup field from Order to the Factory Object to add the Factory.name on the order. The filter would be based on the customer name where I would like to run the update script for each customer separately. The upate would be all orders with the name of "Account Name to be added" , (preference would be to include multiple account names), and the Factory Name would = "Wolverhampton". I am not very well versed with DML or SFCD sql , however if someone could kindly provide the statement structure I would be very gratelful.
Many thanks
Toby
Regarding doing it with Process Builder, this is not the best user case for this #clicksnotcode tool because you also need to modify old records and an action that start the process. If for example you want to populate the Factory lookup field everytime you create a new Order, then PB would work, the action is the creation of the Order. Or if you modify the Order then populate the the lookup with the value. The negative aspect is that you would have to go throw all Orders one by one clicking on Save button.
I would go for the script. In order to run it you can open Developer Console and under debug, Open Execute Anonymous Windows.
Then just run:
All Answers
Look at this example. Think that CO1 is your Factory object and CO2 is your Order object
Go to Order and create the formula field. These are the steps:
1st - Select formula type
2nd - Select your formula type. Text would be good
3rd - Add the formula type. In my case CO1__c.Name instead of your Factory__c.Name
Having this, by the time you populate the lookup to Factory, the formula field would be populated automatically, getting this result:
If you don't have your Order lookup field to Factory populated, then you need a piece of code to do it. Then the formula would work in a similar way. A simple piece of code would be something like this: Plese take into account I just compile it but I didn't try
Hope this help
Regarding doing it with Process Builder, this is not the best user case for this #clicksnotcode tool because you also need to modify old records and an action that start the process. If for example you want to populate the Factory lookup field everytime you create a new Order, then PB would work, the action is the creation of the Order. Or if you modify the Order then populate the the lookup with the value. The negative aspect is that you would have to go throw all Orders one by one clicking on Save button.
I would go for the script. In order to run it you can open Developer Console and under debug, Open Execute Anonymous Windows.
Then just run:
Toby