Link Employee to User in API - acumatica

Using version 21.210. I am able to create a user via the Contract-Based REST api and I am able to create an employee. How can I link the employee to the user? So, I want to do the equivalent of selecting a "Linked Entity" on the Users screen (SM201010).
I see a ContactID field in the Employee/ContactInfo entity but, it doesn't appear to be mapped to anything. Also, it doesn't show on the entity when I query any employee using a GET and $Expand. I'm thinking that I could use the ContactID from the Employee to plug into the "LinkedEntity" field on the User.
Any thoughts would be great.
TIA!

It is linked by the UserID field on the Contact record(that is linked to the Employee via the Employee.DefContactID field). Users.ContactID is a virtual field but in the RowSelecting event it is populated by selecting a contact record where Contact.UserID is equal to Users.PKID.
So you would need to set the UserID field on the employee's Contact record to the user's PKID value. In addition there is also Employee.UserID that you would want to set equal to the Users.PKID value. The virtual field is populated using that Contact.UserID value but in the RowUpdating handler Acumatica is updating both the Contact and Employee records when Users.ContactID is changed.

Related

Display Customer Activity Notes on Sales Order After CustomerID entered

I have a request from a pop up of the Customers Activity Notes after the Customer ID has been entered on a sales order. Currently they have set up specific instructions for entering an order for customer (could be different for each customer). We have entered them under the customers Activity Notes with a specific ID in the subject field. The notes will be in the body of the activity.
Rather then copy this info to the Sales Order Activity Notes, they would just like to display the Activity Notes from the Customers Activity Notes.
Has anyone done something like this or have any though as to how this could be accomplished.
You could proceed one of two ways:
First way is you could create a button in which it would fetch the associated customer's notes and display them.
The second way is that you could override the PXSelecting action for the page and make sure the Customer ID selector has commit changes set to true.
Either way you go, you will need to fetch the notes using the customer's NoteID field from the Note table. One method would be:
BAccount cust = PXSelect<BAccount, Where<BAccount.bAccountID, Equal<Current<SOOrder.customerID>>>>.Select(Base);
Note custNote = PXSelect<Note, Where<Note.noteID, Equal<Required<BAccount.noteID>>>>.Select(Base, cust.NoteID);
This should get you the result you desire. You can then display it however you choose.
NOTE: Please let me know if there are any syntax errors and I will correct them ASAP.

CRM Auto Populate Field From Option Set

I have an Incident entity in CRM 2016 that has an ownerID which relates to a User entity. On that User entity, I have a Location field, which is based on a global option set.
On my Incident form, how would I be able to automatically populate a location field, based on the owner that's selected?
If you just need to show the value you can create a Quick View Form and put it on the form.
If you need to copy the value, because it's a lookup, you can create a Workflow that will copy the value when the record is created or reassigned.
Or - Adding to Guido's Answer - if you want the user to be able to see the value on the form when it loads, you'll need to use the Rest API to query for the Location value of the owner. Use the FetchXmlBuilder for the XrmToolBox to generate the URL that you'll need.

SharePoint 365 - Get user name based on user id returned from api to separate list

I'm getting a user id number back when I API a person field on a list. I'm hoping someone knows of an easy way to get the user name value for a particular user id.
My goal is to populate a person field in my current list form with a value from a person field in another list based on certain conditions, but unfortunately I'm not sure how to utilize the user id toward this end.
I think I figured it out. Instead of using a people picker I used an ASP textbox and databind to update to the user id. Appears to work.

Is it possible to query N:N relationships in a Dialog Query CRM Data step?

I have a custom entity called Department with a N:N relationship with the User entity. I have a lookup field on the Case entity for Department. I added some javascript to the onChange event of the Department field that will query the Department entity and get the users associated with it. If there is only 1 user it sets the Assigned To field on the case to that user. If there are more than one it kicks off a dialog that lets the user select which of the users associated with the Department that the case should be assigned to.
In the Dialog I'm using a Query CRM Data step to get the Users associated with a department but I can't figure out how. I thought with the N:N there would be an entry in the Related section when building the query. There are entries for Departments but they are for Created By, Modified By, and Owning User. Is it possible? Is there a better way to do what I'm trying to do?
You need to use a SOAP call to retrieve all the Users associated with Department. For every N:N relationship there will be an Intersect entity and you need to identify that intersect entity name from N:N relationship in System Customization as in below fig. Here I'm retrieving all the Teams associated with User. In the same way you can retrieve the Users by passing Department Id.
Note: Replace " <q1:Operator>EqualUserId</q1:Operator>" + with below code
" <q1:Operator>Equal</q1:Operator>" +
"<q1:Values>" +
"<q1:Value xsi:type=\"xsd:string\">" + _departmentId + "</q1:Value>" +
"</q1:Values>" +

How to reuse the Entity Field in CRM 2011

I created an entity name is Student,
In that entity I created fields like Name , Age, Qualification etc.,
I wanted to add new field that is Contact number but I don't want to create new one.
Is there any chance to reuse the Mobile phone filed that is presented in Contact Entity..
If there how..??
Please help me..!!
No, you cannot move the mobile phone field from the Contact entity to the Student entity.
You will have to make a new field on the Student and hide the field on the Contact.
Or you could, add a lookup on your student to contact, so each student has a contact record associated and use the phone number that way.
Or you could, get rid of the student entity and just use the contact with the extra fields you needs, as a student is effectively a person which is effectively a contact.
The choice relies on your business requirements.
Yes, you can.
You need to create a htm webresource and retrieve the contact number in the webresource, and then insert this htm webresource into the form.
Please see this article for details:
http://www.gapconsulting.co.uk/DesktopModules/SunBlog/Handlers/Print.aspx?entryid=58

Resources