How can I programmatically assign a Related Entity
I need to programmatically tie an email to a Case. The code I have makes some kind of association, because the email will display in the Case activities. However, the email ‘Related Entity’ field remains blank.
I’ve tried using Base.CurrentMessage and Base.Message. Both assign the correct value. Neither populate the UI field correctly.
@Deetz can you add screenshots as well? What do you expect to see in UI field? Why you don’t like what you see in UI field? What should be there instead?
@yuriyzaletskyy69Â
The right thing (achieve from UI):Â
The wrong thing (achieved through code):
Â
Hi, @Deetz I just tried with your code but was unable to compile and get the error below. I’m missing something?
Â
Â
Â
@Deetz few more questions, which build of Acumatica you use, and which exactly screenid you try to customize?
@yuriyzaletskyy69Â -Â 21.204.0055 and CR.30.60.15
Â
@Naveen B - It’s just a method that returns a Case to attach the Activity too. You can write a simple BQL select to get a Case.
@DeetzÂ
I’m looking on  CRSMEmail declaration, and see that it is a PXProjection :Â
If to sum up, in order for your entity to work, it must satisfy following criteria:
is should correspond to PXProjection requirements, which states that NoteID should have record in SMEmail, classID should be equal to email or class id equal to email routing
It should live in table CRActivity
Without 1 and 2 satisfied, Acumatica will either crash, or behave in a strange way.
Â
@yuriyzaletskyy69 I’m not sure I’m following. It sounds like those requirements would be for creating a new CRSMEmail, which is not what I’m doing. I’m simply trying to add the CRSMEmail to a Case via the RefNoteID. This works in the backend, as it shows up under the Case’s Activity tab, but the CRSMEmail ‘Related Entity’ field doesn’t give the entity description like it’s supposed to. This is a calculated field on CRActivity (PXFormula). I’m not sure how to accomplish this.
Hi @darylbowman were you ever able to resolve your issue? Thank you!
// Reassign Appointment to Case instead, so the Case's 'Appointment Date' is correct bAccountGraph.Activities.Current = bAccountGraph.Activities.Search<CRPMTimeActivity.noteID>(appointment.NoteID); bAccountGraph.Activities.SetValueExt<CRPMTimeActivity.refNoteID>(appointment, taxCase.NoteID); bAccountGraph.Activities.Update(appointment); bAccountGraph.Actions.PressSave();