--- title: Example custom scripts for Password Reset description: The example scripts perform a user account lookup and processes an identification form, define a credential store, and create an identification type. locale: en-US canonical_url: https://www.servicenow.com/docs/r/australia/servicenow-platform/password-reset/r\_PasswordResetScriptingExamples.html release: australia product: Password Reset classification: password-reset topic_type: reference last_updated: "2026-03-12" reading_time_minutes: 5 breadcrumb: [Password Reset script includes, Password Reset reference, Password Reset, Manage service capabilities, Extend ServiceNow AI Platform capabilities] --- # Example custom scripts for Password Reset The example scripts perform a user account lookup and processes an identification form, define a credential store, and create an identification type. ## Perform a user account lookup and process an identification form The main script calls two extension scripts, one to perform the user account lookup, and the other to process the identification form. ``` // User account lookup var lookupExtensionSysId = getExtensionScriptSysId('SampleUserAccountLookupExtension', 'user_account_lookup'); var lookupExtension = new SNC.PwdExtensionPoint(lookupExtensionSysId); // Setup parameters required for this extension type - userId var params = new SNC.PwdExtensionPointParameter() ; params.userId= 'joe.employee'; // Invoke the extension var answer = lookupExtension.process(params); gs.print('user: ' + answer); //Form processor sample - Identification form processor var identExtensionSysId = getExtensionScriptSysId('SampleIdentificationProcessorExtension', 'identification_form_processor'); var identificationExtension = new SNC.PwdExtensionPoint(identExtensionSysId); // Setup parameters required for this extension type - processId var params = new SNC.PwdExtensionPointParameter() ; params.processId = 'pwdreq1234'; // Simulate the posted form parameter for the indentification processor var request = new SNC.PwdExtensionPointParameter() ; // A real life case will inject it's own request object request.setParameter('sysparm_user_id', 'joe.employee'); var userIdentity = identificationExtension.processForm(params, request); gs.print('identity: ' + userIdentity); // Simple helper to return the sys-id for a given extension script function getExtensionScriptSysId(scriptName, category) { var result; var now_GR = new GlideRecord('sys_script_include'); gr.addQuery('name', scriptName); gr.addQuery('script', 'CONTAINS', 'category: \'password_reset.extension.' + category + '\''); gr.query(); if (gr.next() ) { result = gr.getValue('sys_id'); } return result; } ``` ## Define a credential store The following is an example of an extended process function in the User Account Lookup category used to define a credential store. To create this extension script, go to **Password Reset** > **Extensions** > **New extension script** and create a new script as described in [Create an Extension Script](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/servicenow-platform/password-reset/t_CreateAnExtensionScript.md). To configure the User Lookup in a Password Reset process, see [Credential Stores](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/servicenow-platform/password-reset/c_CredentialStores.md). ``` true false Simple account lookup that returns the supplied user id SampleUserAccountLookupExtension admin 2013-07-30 16:44:55 2df5a103d73201002bb9af728e610333 1 admin 2013-07-30 16:46:00 false false !!1W4/ admin 2013-07-30 16:44:55 8306e143d73201002bb9af728e6103d3 0 SampleUserAccountLookupExtension !!1W4/ false 2df5a103d73201002bb9af728e610333 sys_script_include code sys_script_include_2df5a103d73201002bb9af728e610333 admin 2013-07-30 16:46:00 ``` ## Create an identification type The following is an example of an extended processForm function in the Identification Form Processor category that can be used to create an identification type. To create this extension script, go to **Password Reset** > **Extensions** > **New extension script** and create a new script as described in [Create an Extension Script](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/servicenow-platform/password-reset/t_CreateAnExtensionScript.md). ``` true false Script that processes an identification form. Returns the sys-id of the user that corresponds to the requested input; if no user was found, null should be returned. SampleIdentificationProcessorExtension admin 2013-07-30 17:00:28 3a79a503d73201002bb9af728e610349 1 admin 2013-07-30 17:08:41 false false !!1W5/ admin 2013-07-30 17:00:28 4799ed03d73201002bb9af728e610333 0 SampleIdentificationProcessorExtension !!1W5/ false 3a79a503d73201002bb9af728e610349 sys_script_include code sys_script_include_3a79a503d73201002bb9af728e610349 admin 2013-07-30 17:08:41 ``` ## Use the process and processForm extensions This example shows a script that uses two sample extensions, one process extension and one processForm extension. ``` // User account lookup var lookupExtensionSysId = getExtensionScriptSysId('SampleUserAccountLookupExtension','user_account_lookup'); var lookupExtension =new SNC.PwdExtensionPoint(lookupExtensionSysId); // Setup parameters required for this extension type - userId var params =new SNC.PwdExtensionPointParameter(); params.userId='joe.employee'; // Invoke the extension var answer = lookupExtension.process(params); gs.print('user: '+ answer); //Form processor sample - Identification form processor var identExtensionSysId = getExtensionScriptSysId('SampleIdentificationProcessorExtension','identification_form_processor'); var identificationExtension =new SNC.PwdExtensionPoint(identExtensionSysId); // Setup parameters required for this extension type - processId var params =new SNC.PwdExtensionPointParameter(); params.processId='pwdreq1234'; // Simulate the posted form parameter for the indentification processor var request =new SNC.PwdExtensionPointParameter();// A real life case will inject it's own request object request.setParameter('sysparm_user_id','joe.employee'); var userIdentity = identificationExtension.processForm(params, request); gs.print('identity: '+ userIdentity); // Simple helper to return the sys-id for a given extension scriptfunction getExtensionScriptSysId(scriptName, category){ var result; var now_GR =new GlideRecord('sys_script_include'); gr.addQuery('name', scriptName); gr.addQuery('script','CONTAINS','category: \'password_reset.extension.'+ category +'\''); gr.query(); if(gr.next()){ result = gr.getValue('sys_id');}return result;} ``` process function: ``` truefalseSimple account lookup that returns the supplied user idSampleUserAccountLookupExtensionadmin2013-07-3016:44:552df5a103d73201002bb9af728e6103331admin2013-07-3016:46:00falsefalse!!1W4/admin2013-07-3016:44:558306e143d73201002bb9af728e6103d30SampleUserAccountLookupExtension!!1W4/false2df5a103d73201002bb9af728e610333sys_script_includecodesys_script_include_2df5a103d73201002bb9af728e610333admin2013-07-3016:46:00 ``` processForm function: ``` truefalseScript that processes an identification form. Returns the sys-id of the user that corresponds to the requested input;if no user was found,null should be returned. SampleIdentificationProcessorExtensionadmin2013-07-3017:00:283a79a503d73201002bb9af728e6103491admin2013-07-3017:08:41falsefalse!!1W5/admin2013-07-3017:00:284799ed03d73201002bb9af728e6103330SampleIdentificationProcessorExtension!!1W5/false3a79a503d73201002bb9af728e610349sys_script_includecodesys_script_include_3a79a503d73201002bb9af728e610349admin2013-07-3017:08:41 ```