Wednesday, 3 June 2009

Setting advance filtering queries similar to other user in Axapta

Setting advance filtering queries for a particular user similar to another user is a normal requirement.
Example: Users Use Saved Advanced Filtering queries on the Item Details form to search for items. If the same queries are required by another users, a time consuming and cumbersome way is to manually set up these queries for each and every user.
How can we quickly copy the query parameters/criteria from one user to another user?
Use the code below:
Note: change the values of fromUserId and toUserId depending on the requirement.

static void CopyAdvanceFilterQueries(Args _args)

{

SysLastValue sysLastValue;

UserId fromUserId, toUserId;

;

fromUserId = "user1";

toUserId = "user2";

while select sysLastValue

where sysLastValue.recordType == UtilElementType::UserSetupQuery

&& sysLastValue.UserId == fromUserId

{

sysLastValue.UserId = toUserId;

sysLastValue.RecId = 0;

sysLastValue.insert();

}

}

No comments:

Post a Comment