- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2023 05:52 AM
I have a custom widget where we are using 1 input field from user table using record-picker.
"<sn-record-picker field="com_id" table="'sys_user'" display-field="'user_name'" value-field="'sys_id'" search-fields="'user_name'" page-size="100" default-query="'active=true'"></sn-record-picker>"
And after selecting others fields, it create record in 1 custom table "sn_hr_core_profile_master"
I want that if next time any user select same employee and if for him already record created and isactive then it should not submit it and through error that record already exists for user name "user_name".
How can i achive it.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2023 07:02 AM - edited ‎07-26-2023 07:04 AM
Hi @Hafsa1 ,
Hope you are doing well,
Please refer to the script below -
HTML
<div>
<sn-record-picker field="com_id" table="'sys_user'" display-field="'user_name'" value-field="'sys_id'" search-fields="'user_name'" page-size="100" default-query="'active=true'"></sn-record-picker>
</div>
Client
api.controller=function($scope) {
/* widget controller */
var c = this;
c.data.user = "";
$scope.com_id={
displayValue:c.data.user_name,
value:c.data.sys_id,
name:"user"
};
$scope.$on("field.change",function(event,param){
c.data.user = $scope.com_id.value;
c.server.update();
})
};
Server
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
if(input)
gs.addErrorMessage(input.user);
// Use Glide Record to check if request raised
})();
Please mark this response as correct or helpful if it assisted you with your question.
Regards,
Harshal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2023 12:12 AM
Thanks got it