Solved

Create Issue from Button

  • 16 June 2022
  • 5 replies
  • 105 views

Userlevel 4
Badge +1

Hello- I am relatively new to the Acumatica developer side. I am trying to get a button to create an inventory issue auto-populated from results in the grid that the button sits on, however, I’m being stopped in my tracks when I try to create the script to be called because I have no clue if I am calling the correct definitions or not. I am honestly just trying to copy and adapt based on the T230_Actions developer course. I have no clue if I am actually calling to an appropriate object. Any help would be greatly appreciated.

    #region Actions

public static void CreateIssue(INIssueEntry projIssue)
{
using (var ts = new PXTransactionScope())
{
var issueEntry = PXGraph.CreateInstance<INIssueEntry>();
}

...more code would go here

}

#endregion

On a somewhat related note, going through the developer courses, they seem to be pretty rigid regarding the references to classes, names, etc. Short of deploying a local instance and importing the dll via Visual Studio and trying to reverse engineer from there, is there a way to be able to locate definitions? I went to the source code for issues and wasn’t able to find anything to bounce off of, which is usually my go-to to reverse engineer a solution. Projects has a pretty robust method library so I am able to collect some good references but issues just seem to be lacking.

I have also attached my current customization project for reference. I have started the method in the ProjectEntry code section.

icon

Best answer by rosenjon 17 June 2022, 00:15

View original

5 replies

Userlevel 7
Badge +5

Welcome!  I’m relatively new to the Acumatica space and framework so I know where you’re at.

To cover your question around sources: Absolutely install Acumatica locally.  I have multiple installations. Originally I went with virtual machines but when I found this link I dropped that in favour of separate installs and I’ve been happy with the performance.

That will give you access to the source files which I reference all the time.

 

Userlevel 6
Badge +5

@rhooper91 

Here is a search of my App_Data\CodeRepository folder for INIssueEntry. Looks like 171 hits, so should be a lot of examples there. You can also see a file path example….if you find the file path to your site in IIS, it will be obvious where to search. I use Notepad++ to search, but any tool like that will work.

Most of the time you will not have to get into inspecting dll’s for code (at least at this stage in the game). But as you get more into Acumatica development, that may come into play depending on what you’re trying to do.

I think there are some things wrong with what you’re trying to do in your code to link a button to a graph action, but I think it would be helpful if you start by searching the code base as you suggested (this is a good idea!), and then we can help you after you have taken a look at the various examples avaialble.

 

Userlevel 4
Badge +1

Hey all, thanks for the response. I’m going to do some digging and come back to the table if I get any farther with this. Had to put this on the backburner to deal with some more pressing items. 

Userlevel 4
Badge +1

Ok, I have some developments on the code aspect. Please see below. I am essentially

  1. creating a view based on the current context of the project that I’m in
  2. Then I use the view to then create a header - INTranRegister
  3. Foreach result in the table, I generate a new transaction in the grid - INTran
  4. I then redirect the user to the popup screen
        #region Actions

public static void CreateIssue()
{
INIssueEntry graph = PXGraph.CreateInstance<INIssueEntry>();

INRegister header = new INRegister()
{
//BranchID = ,
//DocType = ,
//SiteID = ,
//TranDate = ,
//FinPeriodID = ,
//OrigModule = ,
};

header = graph.issue.Insert(header);
header = graph.issue.Update(header);

foreach (PXResult<PMLotSerialStatus> res in PXSelect<PMLotSerialStatus, Where<PMLotSerialStatus.projectID, Equal<Current<PMProject.contractID>>, And<PMLotSerialStatus.qtyAvail, NotEqual<SQLConstants.Z>>>>.Select(graph))
{
PMLotSerialStatus LSS = res;
INTran newline = new INTran()
{
InventoryID = LSS.InventoryID
};

newline = graph.transactions.Insert(newline);
newline = graph.transactions.Update(newline);
};

if (graph != null)
{
PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.Popup);
}
}

#endregion

Visual has validated this and I am able to build it. I went to try and apply this code to a button but it appears to not be doing anything. Can I get some assistance with validating the logic above? Not sure if that is causing no action or if I just haven’t linked the button that I created through the UI with the method I’ve created in the dll file. 

Thanks in advance!

Userlevel 4
Badge +1

Update… realized that I can’t simply create a method and call it, I have to use a parent function to do it correctly. updated code. It now pulls up the issue screen but doesn’t fill in any transaction lines. Any ideas?

        #region Actions

public PXAction<PMProject> createIssue;
[PXUIField(DisplayName = "Create Issue", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXButton]
protected virtual IEnumerable CreateIssue(PXAdapter adapter)
{
INIssueEntry graph = PXGraph.CreateInstance<INIssueEntry>();

INRegister header = new INRegister()
{
//BranchID = ,
//DocType = ,
//SiteID = ,
//TranDate = ,
//FinPeriodID = ,
//OrigModule = ,
};

header = graph.issue.Insert(header);
header = graph.issue.Update(header);

foreach (PXResult<PMLotSerialStatus> res in PXSelect<PMLotSerialStatus, Where<PMLotSerialStatus.projectID, Equal<Current<PMProject.contractID>>, And<PMLotSerialStatus.qtyAvail, NotEqual<decimal0>>>>.Select(graph))
{
PMLotSerialStatus LSS = res;
INTran newline = new INTran()
{
SiteID = LSS.SiteID,
InventoryID = LSS.InventoryID,
LocationID = LSS.LocationID,
Qty = LSS.QtyAvail,
LotSerialNbr = LSS.LotSerialNbr
};

newline = graph.transactions.Insert(newline);
newline = graph.transactions.Update(newline);
};

if (graph != null)
{
PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.Popup);
}

return adapter.Get();

}

#endregion

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved