Salesforce trigger update field based on another field

All rights reserved. Various trademarks held by their respective owners. If you can't find what you're looking for, contact Salesforce Customer Support. Powered by Community Cloud. Sign Up Log In. Open Avatar Menu. Salesforce Trailblazer Community Community. Log Out. Learn more. New here? Sign Up Have an account?

Sign In. Ask Search: Reset Search. Welcome to Support! Search for an answer or ask a question of the zone or Customer Support.

Need help? Best Answer chosen by Nikita Ghosh. Nitish Singhal I think the only solution looks like is a simple apex trigger which compares the values of all related opportunities and then populates the SL Owner accordingly on the Account level. Nikita, you may need the help of a developer in achieving the same, as I don't see any point and click way to do the same because you need to decide the date and owner from comparing all the child opportunities and there is no way in configuration to do the same.

salesforce trigger update field based on another field

A trigger will be able to do the same. Please let me know if you have any further question. Nikita Ghosh Hi Sunil Account and Opportunity have a master-detail relationship but I want them to auto populate as don't want to give this command to Sales people to populate by lookup.

As I am able to capture SL Date with the help of roll up builder app but getting an error with the owner field. I will look on this with the help of developer hopefully. Nitish Singhal Please mark the answer which gave you the approach for the solution. It will help other community members in future for the similar issue.

Sunil Sarilla Hi Nikita, You can still doing something declaratively using Flows but since you mentioned Rollup builder app, is that Rollup Helper, if so, you can do something using PB.

Nikita Ghosh Hi Sunil, Yes, I am using Rollup Helper but the issue is we don't have the full version because of that it just allow building only 3 rollups formula at the moment. You need to sign in to do that. Need an account? Sign Up. Have an account? Salesforce Salesforce. Need Help?Any other ideas on how to do this? My feeling is that Apex Trigger is my only hope but I have no ability to code this. Let me know your thoughts. All rights reserved. Various trademarks held by their respective owners.

If you can't find what you're looking for, contact Salesforce Customer Support. Powered by Community Cloud. Sign Up Log In. Open Avatar Menu. Salesforce Trailblazer Community Community. Log Out. Learn more. New here?

Automatically update field based on value in another field

Sign Up Have an account? Sign In. Ask Search: Reset Search. Welcome to Support! Search for an answer or ask a question of the zone or Customer Support. Need help? Amnon Kruvi Hi Howard, It sounds to me like you're trying to match zip codes to countries.Field updates allow you to automatically specify a field value. Field updates are actions associated with workflow rulesapproval processesor entitlement processes. Before you begin using field updates, review Field Update Considerations.

All rights reserved. Various trademarks held by their respective owners. If you can't find what you're looking for, contact Salesforce Customer Support. Powered by Community Cloud. Sign Up Log In.

Open Avatar Menu. Salesforce Trailblazer Community Community. Log Out.

salesforce trigger update field based on another field

Learn more. New here? Sign Up Have an account? Sign In. Ask Search: Reset Search. Welcome to Support! Search for an answer or ask a question of the zone or Customer Support.

Need help? Within Opportunities, my user wants a field populated based on whether another field was populated. Example: The stage name would be changed if one of our custom milepost date fields are populated. Syed Y. Talha for this kind of thing you can use workflow field update.

Click New Field Update to define a new field update. Select an existing field update to view details about it or view workflow rules and approval processes that use it. Click Edit to make changes to an existing field update. Click Del to delete a field update. See Also: Defining Field Updates.

Managing Workflow and Approvals. Managing Workflow Rules.You are right, I do not want to duplicate the data in the account fields -- I just want the user to see the info that corresponds to the "number" field selection. It's ok if these don't show up until the record is saved. Login with Salesforce. Ask Search: Reset Search. Welcome to Support! Search for an answer or ask a question of the zone or Customer Support. Need help?

salesforce trigger update field based on another field

You need to sign in to do that Sign in to start searching questions Don't have an account? Signup for a Developer Edition. You need to sign in to do that Sign in to start a discussion Don't have an account? On the account view, I have placed a picklist with the numbers 1 through 5 to match the "number" field in the custom object. The Force. Note that you will not be able to do this instantly in edit mode -- it will only happen once you save the account, and then the trigger can run and update the other fields.

That said, are you sure you want to duplicate the data in that custom object into the Account fields? What if you need to change a name -- then won't you have to go through all Accounts and change it in all of them? You might actually be better served by making a lookup from account to your custom object, and setting that lookup through your trigger instead you'll still need a trigger to set that lookup though. In the Summer release you'll be able to make formula fields that get data from parent objects like your custom object, so you could make those name and person fields as formula fields.

Then if you change the data in the custom object, your accounts will just automatically inherit that change. Steve Bair Thanks. It seems like a trigger would be overkill. Could this be done with a formula?By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up. If this field is already updated and I update any other fields in my Account the trigger should not. The trigger can't be fired. For this, you can reference the Trigger. So, you can compare old values with new values. For example:. So, the Trigger will always 'fire' but you will only act upon it if the new and old values are different i.

Sign up to join this community. The best answers are voted up and rise to the top. Home Questions Tags Users Unanswered. Just update when a specific field changes Ask Question. Asked 6 years, 11 months ago. Active 1 year, 10 months ago. Viewed 49k times. Thanks Phil! I just made some changes and works perfectly! So: for Account acc: Trigger. ID ; if acc.

Markus Slabina 9, 1 1 gold badge 16 16 silver badges 37 37 bronze badges. I assume it's translation thing, but can you be more specific?

Great, glad it worked Everton CP7, if click on the Tick next to my answer, that marks it as answered. Active Oldest Votes. For example: for Id accountId : Trigger. Phil Hawthorn Phil Hawthorn Help I have almost the same problem, however, it doesn't seem to be working for me. I believe you need to change Account to Id in the for loop. At least I did. Sign up or log in Sign up using Google.

Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Featured on Meta. Community and Moderator guidelines for escalating issues via new response….

Feedback on Q2 Community Roadmap. Linked 0. Related 1.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. The dark mode beta is finally here. Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. New to apex and have a question about writing triggers. More specifically, when a custom Account lookup field lookup value is a custom object record is updated, it should update another field with a different value from the custom object record.

When I update the High School name to Elm High School, it will also update the yield associated with that high school. The problem here is that the value of a lookup field is not actually a string as displayed in the UI but an ID, so when you perform your SOQL query you are comparing an ID to the Name field and getting no results.

It should also be notified that this simple use case could also be accomplished using a simple Workflow Field Update rather than a trigger. Learn more. Asked 6 years, 1 month ago. Active 6 years, 1 month ago. Viewed 15k times. Name ; if a!

Any help would be greatly appreciated. Thanks in advance. Active Oldest Votes. If you change your code to the following you should get the result you expect.

Alex Tennant Alex Tennant 3 3 silver badges 8 8 bronze badges.

salesforce trigger update field based on another field

Thanks for the response! You were correct, Workflow rule on a field update was much easier and less complicated. I would up vote you however, Stack Exchange won't let me until my reputation is at least a 15 so consider this a thumbs up. Glad I could be of help. Thanks again. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name.

Workflow to insert value in field based on another field's value

Email Required, but never shown. The Overflow Blog. Featured on Meta.All rights reserved. Various trademarks held by their respective owners. If you can't find what you're looking for, contact Salesforce Customer Support. Powered by Community Cloud. Sign Up Log In. Open Avatar Menu. Salesforce Trailblazer Community Community. Log Out. Learn more. New here? Sign Up Have an account? Sign In. Ask Search: Reset Search. Welcome to Support! Search for an answer or ask a question of the zone or Customer Support.

Need help? The workflow should only trigger for one record type as well. Best Answer chosen by Jon Parmley. Jon Parmley Thanks for your feedback Heather. I was able to do it in standard workflow and workflow action. The overall condition of the workflow was a simple formula that identifed the Record Type ID.

Heather Glenn I would use process builder.

Workflow to update field based on date in another field

Then you would activate it. Does that make sense? Heather Glenn It's a personal preference, Jon. I prefer PB over workflows but both can handle many of the same functions! Glad you got it owrked out.


comments

Leave a Reply

Your email address will not be published. Required fields are marked *