You need to sign in to do that
Don't have an account?
ashu 6112
Trigger Related Task
I have one custom object, there are two fields, one multiselect picklist and second Text Field.
In multiselect picklist, there are 5 values : Mango, Apple, Orange, Guava and Grapes.
The requirement is that if I select Mango in picklist, then It needs to show Yellow Color fruit in the second text field.
If I select Apple in picklist , then it must show Red Color fruit in the second text field..
If I select Mango and Orange, then it should show Yellow Color Fruit, red Color Fruit in the second text field.
I need to write a trigger for this. Please help how to acheive the same.
Do I need to store these values, "Yellow Color Fruit", "red Color Fruit" somewhere in the same object....
In multiselect picklist, there are 5 values : Mango, Apple, Orange, Guava and Grapes.
The requirement is that if I select Mango in picklist, then It needs to show Yellow Color fruit in the second text field.
If I select Apple in picklist , then it must show Red Color fruit in the second text field..
If I select Mango and Orange, then it should show Yellow Color Fruit, red Color Fruit in the second text field.
I need to write a trigger for this. Please help how to acheive the same.
Do I need to store these values, "Yellow Color Fruit", "red Color Fruit" somewhere in the same object....
Yes, basically you put the Fruits and colors in a map. As you loop through the records passed into the trigger, you build the text string based on the fruits selected in the picklist. These values are stored separated by a semicolon(;) so you have to split the string by the semicolon, and as you examine each part of the picklist string, you simply build the second Text string based on what you find.. Once that's all done, you can insert the text String you built into the value of the second text field. If this a 'before' trigger, no insert statement needed.
All Answers
Yes, basically you put the Fruits and colors in a map. As you loop through the records passed into the trigger, you build the text string based on the fruits selected in the picklist. These values are stored separated by a semicolon(;) so you have to split the string by the semicolon, and as you examine each part of the picklist string, you simply build the second Text string based on what you find.. Once that's all done, you can insert the text String you built into the value of the second text field. If this a 'before' trigger, no insert statement needed.
Thanks for this but when I am trying to save this trigger, there is an error message that stops it to save. Error message is "Invalid identifier: secondTextFieldValue at line 09 column 20". I put the line number according to your code.
Please suggest.