Need some opinions for autofill a field on save

Hi,

I want to autofill a field in case module when a new case is created.

I want to get the name of the salesman assigned to the account related to this case. I tried some stuff.

First, I tried to autofill with quick search when we select an account, but the problem I faced was that we nearly never use the popup to select the account, so the field_to_name_array don’t really work for me, and I did not find how to autofill only from the Quicksearch.

Then I tried using a workflow. It works, but instead of filling in the name, it fills the ID of the user. So not what I’m looking for either.

The only thing left i see is logic_hook before save, but i want to ask you before going for it, cause its maybe something i just do wrong and there is a better way to do this.

Thank you for your help.

Hi,

Got some update. In fact, there is no username in the account module, the only value stored is the user ID, and that’s not what I’m looking for, so, since I already know how to get the user ID, what should I do to transform it to the username.

The best would be to do all this in a single step, but I don’t think it will work like this. Should I do some logic_hook just to show the username instead of the user ID? and will that work in all the views?

Waiting to talk with someone on this =)

Do you have Jim Mackin’s eBook “SuiteCRM for Developers”? It’s a great resource for this kind of work.

Yeah i do, i bought it after you told me ^^.

This thread was here to know the best way to do it, not really how. There is a lot of way to do what i want but im not sure witch one to use.

Ah, sorry, I am in too many threads in these forums, I can’t keep track of everyone : - )

I am not the best person to advise on customizing code, but I think this kind of thing is normally handled in an after_save logic hook.

Are you working for SalesAgility ? I see that your nearly respond to all the thread on this forum so i was wondering.

And thank you for responding this fast once again.

I started diving into these forums when I was working on a project and had some extra free time which I was supposed to use to study SuiteCRM in depth. So the forums were a learning tool for me, investigating other people’s problems I learned how to navigate the code and troubleshoot and understand the concepts.

Then I just got into the habit : - )