You need to sign in to do that
Don't have an account?
Auto populate a form's lookup field based on parent field
Hello!
I am very new to Visual Force, roughly 4 weeks.
I currently am in the process creating of creating a two page wizard. Pretty standard, multiple steps powered by one controller.
Page One of the wizard allows the user to create an item. (Master-Detail Parent)
Page Two of the wizard allows the user to take that same item and add as many sub-items as they wish. (Child)
Here is my only snag. Due to their relation, SUB-ITEM has a lookup field that is based off the ITEM name.
Upon creating the item and landing on page 2, I do not want the user to manually choose the item name in the subitem lookup field again to associate it with the parent.
What are my options?
1) So far I only attempted a preliminary insert statememt of subitem.item__c = item.name__c which gave me the good old string id error. I assume this is because a lookup does not work simply by pulling the string as im sure it related to the ID on the backend.
2) I figured another way to do it would be writing java script to grab the apex:inputhidden item.name text and paste it into the lookup field.
3) Or possibly use a trigger?
I have stewed on this for awhile but I figured I would mention this on the forums as I do not want a band-aid or a quick fix. I want to learn how to do it the write way as this will be a recurring problem as i continue my development.
In advance, I greatly appreciate your assistance!
Have you tried :
subitem.item__c = item.id ?
All Answers
Have you tried :
subitem.item__c = item.id ?
Yep, i was trying the name field. Also was missing the __r.
Thanks! Kudos to you!