Using IN operator in DAX for RLS - dax

I have a column named Persons that the usernames are inside it like below:
John, Dave, Ava, Chris
I want to use a RLS that get the username of entered user and only show data if the username include in that column.
I know that i can get the entered person username by USERNAME() but i do not know how to write the above expression in DAX.
I have tried the below code in RLS but it gave me an error:
USERNAME() IN [Persons]
any comment is appreciated

Related

Facing issue in laravel orderby

I am facing a issue with laravel order by function.
i want to fetch the records according to country and the result should start from the current user's country.
For example.
if auth user belong to india then list should start from india.
My Current code is
$users = User::where('status', '=',1)->with(['profile'])->latest()->orderBy('last_login', 'desc')->paginate(12);
Thanks
Ok, whatever I've understood, you are looking to sort the data through the country attributes from profiles table, which is in relation with User model, for this you need to use join I'm not sure about your structure so I'm just giving you an example. Suppose you want to sort by profiles => id then you can write something:
Edit: As per the requirement given in comments I would recommend to have something like this:
First of all lets have authenticated user by
$AuthUser = Auth::user();
Then lets call the relation
$users = User::->leftJoinRelations('profile')
->orderByRaw("FIELD(country , ". $AuthUser->profile->country ."), ASC")
->paginate();
So in this way you can have user sorted by authenticated user country. Hope this helps.

Service Now GlideRecord query reference fields

Does Service Now allow querying referenced fields through the GlideRecord? And if so, how?
I have an application with a local user table for preferences specific to the application. When a user fills out a new form, I would like to query the local user table to see if a record exists for the currently logged in user. If it does, then I would like to prefill some of the answers on the form.
My user table has a reference to the sys_user table in order to link the local user record to the actual service now user. When I try to run the script to check the local user table, it returns "sys_idNotValidnull" for the query statement I add.
var lscUser = new GlideRecord('x_wadm_lsc_user');
lscUser.addQuery('UserID', '=', gs.getUserID());
gs.info("Query: "+lscUser.getEncodedQuery());
lscUser.query();
Returns: "Query: sys_idNotValidnull"
If I change the query to search a different string field it works as expected.
var lscUser = new GlideRecord('x_wadm_lsc_user');
lscUser.addQuery('temp', '=', 'dan');
current.temp += " Query: "+lscUser.getEncodedQuery();
Returns: "Query: temp=dan"
I would agree with Dan that the first step should be to confirm the column names. I usually don't take anything for granted, and always double check. You can use the dictionary or right click on the field label and it will show the column name.
I have seen "sys_idNotValidnull", but usually only within scoped applications.

How to join two belongsToMany objects

I am trying to represent friendships in my Laravel project database.
I have created a table profile which contains all user-data.
A second table profile_profile with the columns profile_id and friend_id.
With that I am able to get persons wo wants to be friend with me:
$this->belongsToMany('App\Profile', 'profile_profile', 'friend_id', 'friend_id');
an friends I am want to be befriendet:
$this->belongsToMany('App\Profile', 'profile_profile', 'profile_id', 'friend_id');
But in the end you are only friends if both want that so. So I tried to combined them but join or something similar didn't work.
I did a research on this platform and google over 2 hours. I am afraid that my skills are to limited, but I really like to ask for help.
Thank you in advance.
Quick solution: add another column in the profile_profile table, say, "accepted" as boolean and default to FALSE.
When a user accepts a friend's request, toggle the "accepted" field to TRUE.
Then you could search like $profile->profiles()->wherePivot('accepted', true)->get()

Jdbc statement error

I have problem with such simple thing, sql statement, I have table in database that contains link in varchar(255), people are logged to site by links, so I'm taking logged person name (Getting something like http://something.site.com) and then passing it to method in which I'm query database to get all records where my logged user has entries.
jdbcTemplate.query("Select * from HIRE where USER=(?)",new Object[] { userName },
However it gives no results at all. I have checked the value in HIRE and the userName are exactly the same, what have I missed?

Adding multiple users at a time in joomla

I have created a joomla component where we can upload the csv file which contain the user name and email of many users.I have written query for inserting the data to the jos_users table.The password in auto generated and i have encrypted the password using
$crypt = JUserHelper::getCryptedPassword("blabla", $salt);
I haven't inserted anything in the activation field.
But due to some reasons I cannot login using the username and the password.Should I do any thing else for this ?
Thanks Brent for your time.I have found the answer and is explained below.
For creating new user accounts by script you need to execute three queries.
1)
insert into jos_users (id,name,username,email,password,usertype,block,sendEmail,gid,registerDate,lastvisitDate) values (NULL,'name','username','email','password','Registered','0','0','18','date','date2')
2)
insert into jos_core_acl_aro (id,section_value,value,name) values (NULL, 'users', '(insertid of the above query)', 'name')
3)
insert into jos_core_acl_groups_aro_map (group_id,section_value,aro_id) values (18, '', '(insertid of the above query)')
This worked for me.
In order for a user to be able to log in -
activation field must be blank
user must be enabled
user must be a member of a group

Resources