logo

NJP

Advanced reference qualifier using script include OR Restrict the records in a reference field

Import · Apr 12, 2020 · video

welcome back guys in this video we will discuss about advanced offense modifiers so before moving on to the actual implementation let me just explain to you what is a defense Kelly file it sends qualifier is just a filter which is used to restrict the number of records or the data which is being returned to a friend's field for example if I talk about incident form we have a field assigned to which is also a reference field so as in when a particular assignment book is changed or a new assignment group is assigned to a particular field user records is filtered on the basis of the members of that particular goal which is again happening because of the reference qualifier created for the assigned to field so this is just to filter out the records let me just move on to the implementation and I will go navigate back to my form click on new so if I click on the lookup icon for this user field as of now I can see all the users and chords the sentences and disco user table and ServiceNow the example which I am taking into account over here so I just want to display only those users who are having ID alone in this particular reference field so I will be filtering out those users now to create a reference qualifier I will right click on the user field configure dictionary and by default I can see this is the view which I am getting this is the reference field then reference qualify condition so I will click on advanced thing so that I get more options and for this particular video I will not be explaining simple reference Khalifah and dynamic events well if I the focus will be only on advanced reference qualifier so I will go ahead and click on advanced over here now in this reference qual field I just need to provide my reference qualify condition since the condition which I'm talking about is not directly related to user table but also has a dependency on the whole stable since user has whole table so we cannot directly write some query over here so let it filter out the record now what I'm going to do is I will be creating a script include and from that's the thing cleared my logic will flow and it will return all those users who are having ideal roles in the system so let me create one scripting clue this is the script included I already created and I will be calling this function return idea users now to do that let me just first show you the number of users who are users present in the system alpha with iti alone so there are over 80 users who have an idea load and copy the way from here no I bled to those fish user has whole table and let me input it query the filter out the users are called with IDL goals now I am going to look to all the record let me just open one of the record so every record over here is a combination of fuser which is an offense field goal and fewer the field so I need to work with the user field because I also need to check whether the users active or not or we can skip that condition for now we can just take into account whether users active or not but should have the ID Elul we can do it either this so if I have to give that condition then I can give it by simply navigating to here and I can select active list - I can run the condition I click copy' query so I will update the query which I previously mentioned now I'll have the exact condition which I am looking for let me create a variable named use SS ID to store the fish ID of all those records which will be returned by this way comma separated so I will check first if this does not have any value by default then the selecting uses society I can check whether this particular variable is already having some value or not if it doesn't have any value by default then I will save this value inside this use versus ID equals to my hazard object dot user dot sis and disco ID and if this is not the first record or when the while loop is running then what should happen is everything should be saved in this particular variable comma-separated as I already mentioned so I will again mention that user has old dot user dot sis underscore ID now one thing will be confusing over here that why I am stowing the user Society but I will clarify that in a minute so let me open the user table in my next tab and let me give a condition father to society since I will be filtering the records based on society I will select the conditioners is one off let me copy the society as this usual paste it over there let me copy the society of this user as well I will paste it over here if I than this condition so this is my filtered query which I also call as encoded quali I'll copy this query and then we can write this anywhere let me write it with my script included selves so the format goes is sis ID in then it follows sis IDs of those records separated by a comma so this is the similar format I am going to follow to return the records who have an idea uses so basically I am trying to create an encoded query over here and I will return that query and that query will be applied to the core diction a dictionary level as a reference qualifier and will return only those users who have an idea zone so now I will turn my query in the way I have already explained it to you okay that take something wrong yes so let me just save my code now for my code to work I will have to call my script included in my reference qualifier I will initialize my script included by using new keyword whenever we create an object in JavaScript new keyword is used so here I am creating an object of my practice util script include dot I will call my function which is certain ITIL uses now let me try to save this okay this is something different happened over this wall I selected the condition as advanced but this is they were turned back to simple why this has happened so the reason for doubt is whenever we are using advanced web reference qualifiers we need to use a perfect JavaScript before the query condition I am about to write otherwise it will not work so let me try to save it now and it will be saved successfully so you can see that now it is not averted back to simple reference qualifier now I will go up to my form and click on new again and I'll click on this lookup icon so as of now I can see only one record which is available over here so let us try to figure why only one record is being returned let me go back to the code I owed so there is something bad happened in this port which is returning only the first teaser in the list because if I go to this list James Anderson is the first one in the list so what song my wife starts over then it ends here so return statement should not be inside while otherwise it will only return the first record so I will cut this and I will paste it after my loop has ended now let me save my code again I will navigate back to my form and click on the lookup lift again so I can see there are a total of 70 users over here who are idea losers and all are being returned over here we can match this count with the count available in the user table as well so let me go to my whole stable I will do I'll go by user so there are 70 unique users who are having idea loads and the same is being returned in my form as well total 7 titl users using offense qualifier so this is how we implement an advanced essence qualifier thank you for watching my video and let me know if you guys have any pain point or anything I can help you with and I can create my next video on the topic mentioned by you thank you so much for watching

View original source

https://www.youtube.com/watch?v=mvoGOgZttGQ