Set value to a field of a linked doctype on creation

Hello,

I wonder if it is possible to set a value to a field of a linked doctype when I create a new document.

For example:

Given is an issue which customer field is set.
Then I create a project from within this issue. (Select: “Create a new project” in the project field of this issue.)
It would be nice, to have the customer in the new created project automatically set to the value of the customer field from the issue.

Any help would be appreciated.

Thanks in advance

Buschi

2 Likes

@Buschi,

You can use the before_insert or validate hooks of the Project document and set the customer value from the server script.

And if you wish to use the client script then you can either use frm.add_fetch or frm.set_value to set the customer value.

Thanks, Makarand

1 Like

I’m trying to a similar thing, client side scripting only.

When someone clicks “Create a new project” from the Project field in a Sales Order, I want the current form SO number to populate the Sales Order field in the new Project window that opens.

The Sales Order will always be in draft status when the “Create a new project” button is pressed.

Can’t find example code for doing this with a “Create a new …” button. Any ideas?