Adding Custom Entity Type in CRM Activity for selecting in Relative Entity

Viewed 60

I have implemented CRM activity on the Custom page where the Key Field is SOOrder Type, SOOrder Nbr & Job Code which are stored in custom DAC. I have tried to add the Entity Type listed on Related Entity and I am not able to figure out how to do it. Pls let me know where to add or override the method to Implement the functionality

The following cod used to implement the CRM Activity

public sealed class SOOrderJobActivities : CRActivityList<PSSOOrderJob>
{
    public SOOrderJobActivities(PXGraph graph)
        : base(graph) { }

    protected override RecipientList GetRecipientsFromContext(NotificationUtility utility, string type, object row, NotificationSource source)
    {
        var recipients = new RecipientList();

        var order = _Graph.Caches[typeof(PSSOOrderJob)].Current as PSSOOrderJob;

        if (order == null || source == null)
            return null;
        SOOrder ord = SOOrder.PK.Find(_Graph, order.OrderType, order.OrderNbr);
        var contact = SOOrder.FK.Contact.FindParent(_Graph, ord);

        if (contact == null || contact.EMail == null)
            return null;

        recipients.Add(new NotificationRecipient()
        {
            Active = true,
            AddTo = RecipientAddToAttribute.To,
            Email = contact.EMail
        });

        source.RecipientsBehavior = RecipientsBehaviorAttribute.Override;

        return recipients;
    }
}

enter image description here

Update

After going through the Acumatica code, I have done the following changes

#region Noteid
    [PXNote(ShowInReferenceSelector =true,Selector =typeof(Search2<PSSOOrderJob.jobCode,
        InnerJoin<SOOrder,On<PSSOOrderJob.orderType,Equal<SOOrder.orderType>,And<PSSOOrderJob.orderNbr, Equal<SOOrder.orderNbr>>>>,
        Where<SOOrder.orderType,Equal<Current<PSSOOrderJob.orderType>>,And<SOOrder.orderNbr, Equal<Current<PSSOOrderJob.orderNbr>>>>>))]
    public virtual Guid? Noteid { get; set; }
    public abstract class noteid : PX.Data.BQL.BqlGuid.Field<noteid> { }
    #endregion

The entity comes into selection, But I am not able to select the relative entity document and the value is not getting updated in the related entity field.

enter image description here

The above screenshot the select is missing and not able to select the document

2 Answers

The following steps I have done to add relative Entity for any Activity using custom DAC

1.  Added ShowInReferenceSelector = true in PXNoteID field.
2.  Added Selector in PXNoteID field
3.  Decorated [PX.Data.EP.PXFieldDescription] attribute for Key fields

#region NoteID
    [PXNote(ShowInReferenceSelector = true, Selector = typeof(Search2<PSSOOrderJob.jobCode,
        InnerJoin<SOOrder, On<PSSOOrderJob.orderType, Equal<SOOrder.orderType>, And<PSSOOrderJob.orderNbr, Equal<SOOrder.orderNbr>>>>,
        Where<SOOrder.orderType, Equal<Current<PSSOOrderJob.orderType>>, And<SOOrder.orderNbr, Equal<Current<PSSOOrderJob.orderNbr>>,And<PSSOOrderJob.jobType,Equal<Current<PSSOOrderJob.jobType>>>>>>), DescriptionField = typeof(PSSOOrderJob.jobCode))]
    //[PXNote(ShowInReferenceSelector = true)]
    public virtual Guid? NoteID { get; set; }
    public abstract class noteID : PX.Data.BQL.BqlGuid.Field<noteID> { }
    #endregion

#region JobCode
    [PXDBString(15, IsKey = true, IsUnicode = true, InputMask = ">CCCCCCCCCCCCCCC")]
    [PXUIField(DisplayName = "Job Code")]
    [PXDefault()]
    [PXSelector(typeof(Search<PSSOOrderJob.jobCode, Where<PSSOOrderJob.orderType, Equal<Current<PSSOOrderJob.orderType>>, And<PSSOOrderJob.orderNbr, Equal<Current<PSSOOrderJob.orderNbr>>,And<PSSOOrderJob.jobType, Equal<Current<PSSOOrderJob.jobType>>>>>>), typeof(PSSOOrderJob.jobCode),  ValidateValue = false)]
    [PSSOOrderJobNbr.Numbering()]
    [PX.Data.EP.PXFieldDescription]
    public virtual string JobCode { get; set; }
    public abstract class jobCode : PX.Data.BQL.BqlString.Field<jobCode> { }
    #endregion

This automatically fills the related entity field with Jobcode.

There still one issue I am facing is not able to access the selector due to Entity field width is more than the popup window and I do not know how to fix it.

enter image description here

This answer is to address the popup size only.

enter image description here

First, give browser zoom a try 'control' + 'minus' key. It might work as a quick workaround.

Otherwise, use the browser debugger feature. Open it with F12 key. Then use the browser debugger inspect element feature (1). Click on the smart panel (2). Go up a bit in html control hierarchy until you reach and select the smart panel root which is a table element (3). Change the width of the smart panel popup using the debugger CSS properties editor (4).

If selector control size increases automatically with window size; change the selector control width instead of popup width using browser debugger CSS property editor.

enter image description here

Related