Most unimaginative title I could have come up with! But if it helps you find this page soon then it has served its purpose.
So you know that curUserId() gives you current user and you want to know (for some godforsaken reason) the party rec id that is linked to this user? Well here is the X++ code that will give you the answer.
DirPersonUser::find(curUserId()).PersonParty
Let me explain it now.
1. When a user is created in a system, there is a record created in UserInfo (and probably other tables)
2. The user is not linked to any DirPartyTable record or DirPerson record. You need to explicitly link a user to a DirPerson record. This is done from the form SysUserInfoDetails that opens from the path System Administration->Common->Users.
3. On this form under the menu there is Relations under Setup, there you can link an existing DirPerson record to UserInfo .
4. Behind the scenes this association is stored in the table DirPersonUser
Here is a riddle, what does the following X++ code return? I will explain in my next article in a day or two.
DirPartyRelationship::find(DirRelationshipTypeTable::findBySystemType(DirSystemRelationshipType::TeamMember).RecId, CustCollectionsAgent::collectionsTeam().RecId, DirPersonUser::find(curUserId()).PersonParty));