# Create AOT query for below code

**URL:** <https://www.dynamicsuser.net/t/create-aot-query-for-below-code/78145>\
**Category:** Finance and Operations/AX\
**Tags:** d365fo\
**Created:** [May 18, 2023, 7:43am UTC](https://www.dynamicsuser.net/t/create-aot-query-for-below-code/78145 "2023-05-18T07:43:45Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![MartinDrab](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@MartinDrab](https://www.dynamicsuser.net/u/MartinDrab)\
**Post date:** [May 18, 2023, 8:39am UTC](https://www.dynamicsuser.net/t/create-aot-query-for-below-code/78145/3 "2023-05-18T08:39:19Z")

</div>

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:

```auto
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](https://www.dynamicsuser.net/t/use-of-ai-on-forums/77970)). 😉

---

_[View the full topic](https://www.dynamicsuser.net/t/create-aot-query-for-below-code/78145)._
