Skip to main content

I am preety new in the acumatica customization….is there any chance for me to call external API call so that i can get the data ? after the data is being collected and presented i would like to enable user to select the data which then he can save.

I was thinking to create screen, also to create custom unbound DAC-s but i am not sure how to work with the rest of the requirements, any suggestion would mean a lot.

Maybe i could perform the get method using some other methods….i am currently stuck...at first i was thinking to call Acumatica POST call, but the problem is that i must first perform “login” so that i can “POST” the data, but i must use only one link from that external app….that is the reason which i wanted to create the GET call from the Acumatica itself….

 

If you have a table (DAC) to hold the transactions then you can create a graph to display those transactions in a grid.  That graph can have a PXAction button that the user can click and that allows you to run code to log on to your external API and populate the grid for the user to review and select.

I would expect that you could do this with an unbound DAC, too.


Hi ddun, thank you for your fast reply. The problem is, that i dont have the table which can hold the transaction. The idea is to create unbound DAC which have the same properties as the deserialized json class (response from the GET call of the external API). And to show the GET results to the user. WHen this is done, user can then select the entries from the list and with “Save” button, those entries would be use to create new Acumatica objects and save them into the database. 

The thing is that must have this type of approach becuase with the GET i can also get the files, which i cannot save without previously saved acumatica object (thats how i get the ID where i can attach my file).

The PXAction is a good idea, and it would call the external API - but to i must make a HttpClient within the screen or Acumatica already supports this somehow ? (this part i could not find at all)...


You’ll likely want to build the project in Visual Studio instead of the built-in editor.  Yes, you can pull in other references to get an HttpClient.

There are ways to push records into the Cache of an unbound DAC. Google that - or maybe someone with more experience will join this thread.

https://stackoverflow.com/questions/26558889/in-acumatica-can-you-have-a-graph-page-using-an-unbound-dac

https://stackoverflow.com/questions/48010077/using-unbound-dacs-in-process-graph-fails-to-run-processing-functions

 

 


hu ddunn, thank you for your reply and good examples


I have managed to integrate the call of the HttpClient into my graph. The problem which i am facing is that i cannot figure it out why my view does not receive any of the data. I have also insert them into the cache with a button call but somehow it does not show at all….

In my graph constructor i am only initializing my client and its configuration for the async call.


        public PXFilter<ParticipantFilter> Filter;
        public PXSave<UnboundParticipant> Save;
        public PXCancel<UnboundParticipant> Cancel;

        // master view
        public PXSelect<UnboundParticipant> MasterView;

        #region PXFilteredProcessing

        dPXVirtualDAC]
        PXFilterable]
        public PXFilteredProcessing<UnboundParticipant, ParticipantFilter> UnboundView;

        protected virtual IEnumerable unboundView()
        {
            foreach (UnboundParticipant item in UnboundView.Cache.Cached)
            {
                yield return item;
            }            
        }

        #endregion
        
        #region Actions

        public PXAction<UnboundParticipant> GetData;

        #PXButton]
        PXUIField(DisplayName = "Get Data", Enabled = true)]
        protected virtual void getData()
        {
            PXLongOperation.StartOperation(this, delegate
            {
                GetParticipants();
            });
        }

        private async void GetParticipants()
        {
            UnboundView.Cache.Clear();

            var participants = await this.client.GetParticipants();
            if (participants == null || participants.Count == 0)
            {
                return;
            }

            foreach (var participant in participants)
            {
                var dacParticipant = new UnboundParticipant()
                {
                    Id = participant.Id,
                    FirstName = participant.FirstName,
                    LastName = participant.LastName,
                    Email = participant.Email,
                    Organization = participant.Organization,
                    Phone = participant.Phone,
                    Created = participant.Created,
                    Updated = participant.Updated
                };

                UnboundView.Insert(dacParticipant);
                UnboundView.Cache.Insert(dacParticipant);          
            }
        }

        #endregion


The idea which i had is to fill out the view only when i press the button.But something i am doing wrong….after the data is being filled, user only needs to select the rows and to press new button to save selected data into database.


Reply