Dynamic Creation

robertmaxwell
Mega Expert

On a new call record i am adding new users dynamically when they call for the first time.

I also have the phone number on the form but I can't work out how to add the phone number entered on the form into the new user record that is created

My starting point is:

    current.name = value;

    current.insert();

How do I capture the phone number entered into the record?

Thanks

3 REPLIES 3

Deepak Kumar5
Kilo Sage

var usr = new GlideRecord('sys_user');


  usr.initialize();


  usr.name = 'value you enter';


  usr.email = 'email';


  usr.phone_number = 'phone numer';


  usr.insert();




tanumoy
Tera Guru

Deep's reply will do the job. If not, could you post the full code so that we can understand better.


Kalaiarasan Pus
Giga Sage

Word of caution.



We have something like this and the implementation was not built the right way.



I would advise having a field on the form that can uniquely identify the user (like email) and then use it to create the user record. If not, the system will be full of duplicate records as more users start to use the feature.



This could help you.



var getUser = new GlideRecord('sys_user');


if(!getUser.get('email',current.emailField))


{


getUser.initialize();


getUser.first_name=value;


getUser.email=current.emailField;


getUser.insert();


}