Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

SN Record Picker

Prataps135
Mega Sage

Hi everyone,

 

I just want to show and alert when someone click over the sn-record-picker.
basically i want to trigger something for sn-record-picker on-click functionality. ng-click is not working for it.
So, can you please suggest me any way that how can i achieve this thing for sn-record-picker.

Regards 
Pratap Singh Sisodia

5 REPLIES 5

dgarad
Giga Sage

Hi @Prataps135 

try the below code.

<sn-record-picker  on-change="recordPickerChanged(val)" ></sn-record-picker>

client side
$scope.recordPickerChanged = function recordPickerChanged (newValue) {
	// parameter newValue will contain the new value selected.
};
If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad

Community Alums
Not applicable

Hi @Prataps135 ,

I tried your problem in my PDI and it works for me please check below code 

HTML 

<sn-record-picker field="user_name" sn-change="c.userRecord()"table="'sys_user'" ng-click="c.userRecord()"  display-fields="'email'"  display-field="'user_name'" display-fields="'user_name'" value-field="'user_name'" field="user_name" search-fields="'user_name'" page-size="100" ></sn-record-picker>

Client Script: 

api.controller=function($scope) {
  /* widget controller */
  var c = this;
	c.userRecord = function(){
		alert("TEst")
	}
};

 

Result 

SarthakKashyap_0-1715925668067.png

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards

Sarthak

Prataps135
Mega Sage

Hi @dgarad , @Community Alums 

I got your things but my requirement is that when i open the sn-record-picker by clicking for it without choosing any open just when it opens the drop down at that time i need this alert.
Can you please suggest that how can we achieve that.

Regards 
Pratap Singh Sisodia 

Community Alums
Not applicable

Hi @Prataps135 ,

Please try to use ng-focus instead of ng-click. This will work for you.

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards

Sarthak