Acumatica Load data from external REST service to grid - acumatica

I have a customization project where I'm pulling in some external data from a REST API.
This is all working, but now I'm trying to figure out how to display the data retrieved from the API in a grid on a custom tab.
I created a custom DAC to represent the data, but I'm unsure how to get this into a view object that can be used with a grid.
I tried just defining a List object of my DAC type, but that did not work with the grid.
Any ideas how I can get a list of objects to display in grid.

I solved this by creating a PXSelect variable and creating a view delegate to add the records to the view.

Related

How to Enable Fields when used from API

How can I set fields to be updateable in the API but, read-only on the screen?
I have a view with a custom table defined in a Graph extension. I am using the (ViewName).AllowUpdate = false; on the RowSelected event of the primary DAC. This works fine to make all of the fields in the view disabled on the screen but, I can't update the fields in the API. Is there some way to detect that the graph is being used in the API versus the screen?
TIA!
What you can do is in the row selected event instead of affecting the restriction at cache level, which as you said affects the API as well, you can use the PXUIFieldAttribute to achieve the same scenario without affecting the API.
Ex: PXUIFieldAttribute.SetReadOnly([ViewName].Cache, null, [Condition or just set as true])
This will set all the fields in that view as readonly, without having to repeat the line for all the fields currently in the screen.
I had a similar requirement to allow edit on a custom field in Shipment graph only through API and not through UI.
You could use the Graph.IsContractBasedAPI method that returns true if the request came through contract based API as shown below:
PXUIFieldAttribute.SetEnabled<SOShipLineExt.usrBOLQty>(cache, e.Row, Base.IsContractBasedAPI);

How to get 'Bills and Adjustment' grid fields in an endpoint extension

I'm working with a client on obtaining Bills and Adjustments values through the Contract based web services. I understand that certain fields aren't available in the Default Endpoint, and have to be obtained through an extension.
I'm trying to add fields from the Bills and Adjustments' Applications tab, but I'm running into a warning that I don't understand. If I extend the Default endpoint for 'Bills' (call it 'BillExt'), and I try to add the Reference Number field from the 'Applications' tab/grid (or any other field from that grid) - I get the following warning (see screenshot below)...
Can someone explain what the issue is, and how I go about adding these fields from the 'Applictaions' tab/grid? I've added fields from the 'Approval Details' grid without this warning without a problem. Is this a warning I can disregard?
You are trying to add a field from another table/view that can return multiple rows for a single Bill.
The correct way to do this is by adding a separate collection on the object and map the view on that collection. e.g: Applications or Details collections here.
That collection will have the information for all records related to the header once you retrieve them using the ?$expand=Details on the query string request.

Extend Cases to include an additional tab with a list (AEF)

I have been extending Acumatica screens by adding new fields accordingly. However, for this particular scenario, I want to create a new tab in the Cases screen.
This tab would include a list of items. These list of items would be a custom table that I will be adding to Acumatica.
Is this possible?
And is this the correct list of Steps?
1. Create table in Acumatica for the list of items
2. Create DAC for the new table
3. Extend the Cases Graph and add a new Data View (i.e. PXSelect)
4. Edit the Cases screen so that a table and grid are added accordingly
5. Link the grid to the Data View through the Data Member property
I am not sure whether you would also need to implement some additional events, but I believe that if the DAC has the correct link to the Case and the correct attributes ... it should work.
Would be much appreciated if someone helps to confirm the above approach please.
Adding a tab page containing a grid bound to a DataView on a custom DAC in the case entry screen is a supported scenario.
There are a few ways to do it. Whether you are working on a Customization Project or an Extension Library will influence how you approach this requirement.
Your steps seems all right. Here's how I would do it in a Customization Project:
Create a new table in the database using a DB management utility (ex: SQL Server Management Studio). Restart WebSite instance or IIS to make sure Acumatica picks up DB schema change.
In DB script section of the customization project, add the new table and check import table schema from database. This will ensure publishing the customization project will create the table in the database.
Create a new DAC for the new table, DAC name should be the table name.
Extend the case entry graph (CRCaseMaint) and add a new DataView on your DAC.
Edit the case entry screen (CR306000), add a TabPage and a grid.
Bound the new grid to your DataView using the DataMember property

Xpages Dojo Data Grid - Client Side Sorting

I want to be able to get the data and sort it in-memory. I am able to get JSON data using dojox.data.JsonRestStore. Now my question is how do I store it in memory and do in-memry sorting when I click on Dojo Datagrid headers. From what I have searched so far, it is not possible to sort the datagrid in-memory/client-side as it will request the sorted data from my Rest Service. As it is custom rest service, I am not able to sort the data on server side (or is it possible?).
Thanks in advance.
Arun
Outside of XPages, you should be able to set an attribute of the grid to do this -- clientSort: true
However, this doesn't seem to take effect within XPages. I tried the following, with no success:
Adding a clientSort attribute with a value of true to the grid control (via the Dojo tab). The attribute showed up in the right place in the page source, but had no effect. (Programmatically checking the property returned a value of undefined.
Setting [grid].clientSort = true on the onClientLoad event of the page. When checked programmatically, the property would show that it is now set to true, but it had no effect.
I even tried adding it to a grid created programmatically (without the Dojo Data Grid control) and it had no effect.
It appears that either XPages is wiping out the attribute or that it just doesn't work within XPages with a remote data source. (My first two attempts used a REST service. My third attempt used a remote XML data source.)
I still think it's worth attempting to see whether it works with a local data source (like a read-write item store), but I have not had a chance to try that yet.

Autofilling Part Values in an Orchard Controller

I'm very new to Orchard (and ASP.NET MVC) and I'm having some difficulty wrapping my head around how Orchard part properties can be automatically set in a controller. I have a "Gallery" content type, consisting of the stock Title, Container and Owner parts. I'm creating a controller with a Create method that hides all of the details of the Container part since I'm going to set the default page length, the item type, et cetera in the HttpPost version of the Create method. My problem is I don't know how to set those values on the http Post.
My general plan was as follows:
I created a CreateGalleryViewModel containing the title and admin username, both as a string. IN the view those two are represented as form fields. On the submit, I could run TryUpdateModel in the controller to update the CreateGalleryViewModel with the form values. But then how do I update the Part properties? I think I'm supposed to run IContentManager.UpdateEditor(, this) but I don't think this ca, work because I never ran IContentManager.BuildEditor in the first place. Here's where I'm stuck because I don't see how the content parts get validated and updated properly.
Am I looking at this at the wrong level of abstraction? How do I make a simplified editor for my Gallery content type?
What you basically need to know here is the following:
You can build the editor of a content item with IContentManager.BuildEditor()
You can updated an item's parts' values from the POST data with IContentManager.UpdateEditor()
You can also access parts by "casting" content items with the As() method (needs the Orchard.ContentManagement namespace).
When you're dealing with content items because of their dynamic nature it's rarely a good approach to create a view model where you recreate some of the parts' properties. If you have such static view models for what's contained in a content item then you'll miss the extensibility and flexibility that comes with Orchard's content model. E.g. if you add a new part to that content type since you're using a static view model the new part won't be handled.
For a complete example of how to manage content items from code, see the Training Demo module.

Resources