Skip to main content
Solved

i need to fetch Attention, Email, Phone1 and Phone2 from Contact but this query not working properly


Forum|alt.badge.img

Why Sometimes this query return null and some time it will return result? 

   

 var result = PXSelectReadonly2<PX.Objects.GL.Branch,
        InnerJoin<PX.Objects.GL.DAC.Organization, On<PX.Objects.GL.DAC.Organization.organizationID, Equal<PX.Objects.GL.Branch.organizationID>>,
        InnerJoin<PX.Objects.CR.BAccount, On<PX.Objects.CR.BAccount.bAccountID, Equal<PX.Objects.GL.DAC.Organization.bAccountID>>,
        InnerJoin<PX.Objects.CR.Contact, On<PX.Objects.CR.Contact.contactID, Equal<PX.Objects.CR.BAccount.defContactID>>>>>,
        Where<PX.Objects.GL.Branch.branchID, Equal<Required<PX.Objects.GL.Branch.branchID>>>>.Select(graph, graph.Accessinfo.BranchID);

Best answer by hyadav08

I have found solution the below code given me the correct contact detail
 

List<Contact> contacts = PX.Objects.CS.OrganizationMaint.GetDefaultContactForCurrentOrganization(graph).ToList(); 
            foreach(Contact cont in contacts) { 

                UserTranInfo.ContactName = cont.Attention;
                UserTranInfo.ContactEmail = cont.EMail;
                UserTranInfo.ContactPhone1 = cont.Phone1;
                UserTranInfo.ContactPhone2 = cont.Phone2;
            }

View original
Did this topic help you find an answer to your question?

7 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3404 replies
  • July 4, 2024

@hyadav08  Try the below code and verify.

 

   PX.Objects.CR.BAccount objBAccount = PXSelectJoin<PX.Objects.CR.BAccount, 
                                        InnerJoin<Organization, On<Organization.bAccountID, Equal<PX.Objects.CR.BAccount.bAccountID>>,
                                        InnerJoin<PX.Objects.GL.Branch,On<PX.Objects.GL.Branch.organizationID,Equal<Organization.organizationID>>>>,
                                        Where<PX.Objects.GL.Branch.branchID,Equal<Required<PX.Objects.GL.Branch.branchID>>>>.
                                        Select(customerMaint, customerMaint.Accessinfo?.BranchID); 

   if (objBAccount != null)
   {
       OrganizationMaint OMaint = PXGraph.CreateInstance<OrganizationMaint>();

       OrganizationBAccount OBAccount = PXSelect<OrganizationBAccount, Where<OrganizationBAccount.bAccountID,
                                        Equal<Required<OrganizationBAccount.bAccountID>>>>.Select(OMaint, objBAccount?.BAccountID);
       if (OBAccount != null)
       {
           OMaint.BAccount.Current = OBAccount;

           PX.Objects.CR.Address MainAddress = OMaint.GetExtension<OrganizationMaint.DefContactAddressExt>().DefAddress.Select()[0];
           PX.Objects.CR.Contact MainContact = OMaint.GetExtension<OrganizationMaint.DefContactAddressExt>().DefContact.Select()[0];

		  // Get The Address Details from MainAddress object
		   //Get the Contact Details from MainContact object


	   }
   }

 


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 10 replies
  • July 5, 2024

@Naveen Boga 
I have Try the above code and check objBAccount is null.
Why this is given null to me and also suggest the other solution to extract  Attention, Email, Phone1 and Phone2 from Contact ?


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3404 replies
  • July 5, 2024

@hyadav08 I think this is an issue with your graph i.e. CustomerMaint.

To confirm this, Can you please replace the new PXGraph() ( This is just for your testing and I recommend to use the PXGraph())

 

Once it is confirmed then pass the right graph from your code and verify 


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 10 replies
  • July 5, 2024

@Naveen Boga  We haven’t use  new PXGraph()


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3404 replies
  • July 5, 2024

Sure, Have you tried with right graph and it is working fine?


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 10 replies
  • Answer
  • July 9, 2024

I have found solution the below code given me the correct contact detail
 

List<Contact> contacts = PX.Objects.CS.OrganizationMaint.GetDefaultContactForCurrentOrganization(graph).ToList(); 
            foreach(Contact cont in contacts) { 

                UserTranInfo.ContactName = cont.Attention;
                UserTranInfo.ContactEmail = cont.EMail;
                UserTranInfo.ContactPhone1 = cont.Phone1;
                UserTranInfo.ContactPhone2 = cont.Phone2;
            }


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2754 replies
  • July 9, 2024

Thank you for sharing your solution with the community @hyadav08!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings