Create AOT query for below code

internal final class RunnableClass1
{
///


/// CustomFieldloc we created customfield on HCMsharedparametertable.
public static void main(Args _args)
{

    HcmSharedParameters HcmSharedParametersLoc, HcmSharedParametersLoc1 ;
    UserGroupInfo    UserGroupInfoloc;
    CustomField       CustomFieldloc;
    UserGroupList   UserGroupListloc;

    select  firstonly * from UserGroupInfoloc where UserGroupInfoloc.RecId == HcmSharedParameters::find().CustomFieldloc;
    while select UserGroupListloc where UserGroupListloc.groupId==UserGroupInfoloc.id
    {
        DirPartyName PersonName = DirPersonUser::userId2Name(UserGroupListloc.userId);
    }
}

}

@MartinDrab @Scarlett_Jonathon please suggest

It would help if you explained your problem - it’s not clear which part you’re struggling with.
It may be beneficial for you if you rewrite code to a single query, because that’s what you need in AOT. Then you’ll implement the same structure in AOT.

For example:

DirPerson			person;
DirPersonUser 		personUser;
UserGroupInfo 		userGroupInfo;
HcmSharedParameters hmcSharedParams;
UserGroupList 		userGroupList;

select person
	join personUser
		where personUser.PersonParty == person.RecId
		join userGroupList
			where userGroupList.UserId == personUser.User
			join userGroupInfo
				where userGroupInfo.Id == userGroupList.GroupId
				exists join hmcSharedParams
					where hmcSharedParams.UserGroupInfo == userGroupInfo.RecId;

By the way, Scarlett_Jonathon is an AI bot (source). :wink: