Question about the "Dynamic creation script" field on the dictionary of a reference field.

Jeff316
Kilo Guru

Hi All,

I have a custom reference field on the sc_request form called "reply to". This reference field selects from sys_user table and the reference key is "email". So the user is asked to select/enter an email address into the "reply to" field. 

My question is: If the email address they enter into "reply to" does not exist in the sys_user table, I want a new user record created with that email address. To do this, I think I go to the Dictionary for the "reply to" reference field and on the advanced view, I set the field "Dynamic creation" to true and I need to provide a Dynamic creation script. This is where I get stuck. What is the script needed to create a user record where I only know the email address they enter in the "reply to" field? 

In the doc it shows the example of a dynamic_creation_script as:
current.name = value;
current
.insert();

That alone does not work. what is 'name' and what is 'value'

The field on my form is "reply to" that I want to make to the "email" field on sys_user.

 

1 ACCEPTED SOLUTION

hi Chandu,

 

I figured it out. Script include isn't necessary.

The user record will create automatically.

You can tell the creation_script field which fields to populate.

in this case, the "value" is the text they entered into the reference field that doesn't currently match and record in the user table.

Here you can select which field to place into sys_user as current.email, current.user and current.name.

In my case I want 'value' which is coming from my custom field u_reply_to to populate email user_name and name in the user record but I could also populate other fields in the user form directly in this creation script.

 

current.email=value;
current.user_name=value;
current.name=value;
current.insert();

View solution in original post

2 REPLIES 2

Chandu Telu
Tera Guru
Tera Guru

Hi 

You may call script include and check the user is available in user table or not if not create user in user table

 

Please make this answer is correct if answer your question

Thanks
Chandu

hi Chandu,

 

I figured it out. Script include isn't necessary.

The user record will create automatically.

You can tell the creation_script field which fields to populate.

in this case, the "value" is the text they entered into the reference field that doesn't currently match and record in the user table.

Here you can select which field to place into sys_user as current.email, current.user and current.name.

In my case I want 'value' which is coming from my custom field u_reply_to to populate email user_name and name in the user record but I could also populate other fields in the user form directly in this creation script.

 

current.email=value;
current.user_name=value;
current.name=value;
current.insert();