Skip to main content
Solved

How to access relations view in the sales order graph from another graph - 2022 R2

  • November 9, 2023
  • 1 reply
  • 130 views
  • Translate All

Forum|alt.badge.img

I created a graph from another graph like the one below

SOOrderEntry docgraph = PXGraph.CreateInstance<SOOrderEntry>();

but I couldn't insert the data below for the 2022 R2 version

var relation = docgraph.Relations.Insert();

So how can I insert data to the Relations tab in the sales order screen in the 2022 R2 version? It's working in 21 R1 but it's missing in 2022 R2.

Do you happen to know anything about this?

 

 

Best answer by Sagar Greytrix

Hi @Lalith ,
Could you please try below code snippet to insert data in Relations Tab?

 #region Relation: Opportunity -> Sales order

            var relationExt = docgraph.GetExtension<SOOrderEntry_CRRelationDetailsExt>();

            var opportunity = (CROpportunity)PXSelectReadonly<CROpportunity,
Where<CROpportunity.opportunityID,
Equal<Current<Document.opportunityID>>>>.Select(Base);
             var relation = relationExt.Relations.Insert();

            relation.RefNoteID = salesOrder.NoteID;
            relation.RefEntityType = salesOrder.GetType().FullName;
            relation.Role = CRRoleTypeList.Source;
            relation.TargetType = CRTargetEntityType.CROpportunity;
            relation.TargetNoteID = opportunity.NoteID;
            relation.DocNoteID = opportunity.NoteID;
            relation.EntityID = opportunity.BAccountID;
            relation.ContactID = opportunity.ContactID;

            relationExt.Relations.Update(relation);

#endregion

Hope, it helps!


Regards,

Sagar 

View original

1 reply

Sagar Greytrix
Captain II
Forum|alt.badge.img+3

Hi @Lalith ,
Could you please try below code snippet to insert data in Relations Tab?

 #region Relation: Opportunity -> Sales order

            var relationExt = docgraph.GetExtension<SOOrderEntry_CRRelationDetailsExt>();

            var opportunity = (CROpportunity)PXSelectReadonly<CROpportunity,
Where<CROpportunity.opportunityID,
Equal<Current<Document.opportunityID>>>>.Select(Base);
             var relation = relationExt.Relations.Insert();

            relation.RefNoteID = salesOrder.NoteID;
            relation.RefEntityType = salesOrder.GetType().FullName;
            relation.Role = CRRoleTypeList.Source;
            relation.TargetType = CRTargetEntityType.CROpportunity;
            relation.TargetNoteID = opportunity.NoteID;
            relation.DocNoteID = opportunity.NoteID;
            relation.EntityID = opportunity.BAccountID;
            relation.ContactID = opportunity.ContactID;

            relationExt.Relations.Update(relation);

#endregion

Hope, it helps!


Regards,

Sagar 

Translate