PXGraphExtension CreateInstance method? - acumatica

How to create an instance of a graph extension something like:
MyGraph_Extension graph = PXGraphExtension.CreateInstance<MyGraph_Extension>();

You do not create an instance for an extension graph the same way as the base graph. You use the instance of the base graph and just get your extension graph using GetExtension. Here is an example which is an extension for Sales order entry:
var baseGraph = PXGraph.CreateInstance<SOOrderEntry>();
var extGraph = baseGraph.GetExtension<SOOrderEntryExtension>();

Related

How does one access an Extension to a table in Acumatica Business Logic

Apologies if this question has been answered elsewhere, I have had trouble finding any resources on this.
The scenario is this. I have created a custom field in the Tax Preferences screen called Usrapikey.
This value holds an api key for a call that gets done in some custom business logic.
The custom business logic however occurs on the Taxes screen.
So within the event handler I need to access that API key value from the other screen. I have tried instantiating graphs and using linq and bql but to no avail.
below is what I have currently and my error is: No overload for method 'GetExtension' takes 1 arguments
If I am going about this the wrong way please let me know if there is a more civilized way to do this
protected virtual void _(Events.FieldUpdated<TaxRev, TaxRev.startDate> e)
{
var setup = PXGraph.CreateInstance<TXSetupMaint>();
var TXSetupEX = setup.GetExtension<PX.Objects.TX.TXSetupExt>(setup);
var rateObj = GetValues(e.Row.TaxID, TXSetupEX.Usrapikey);
decimal rate;
var tryRate = (Decimal.TryParse(rateObj.rate.combined_rate, out rate));
row.TaxRate = (decimal)rate * (decimal)100;
row.TaxBucketID = 1;
}
Many Thanks!
Well, acumatica support got back. It seems if you want to access the base page use:
TXSetup txsetup = PXSetup<TXSetup>.Select(Base);
To get the extension use:
TXSetupExt rowExt = PXCache<TXSetup>.GetExtension<TXSetupExt>(txsetup);
Then you can access the extension fields like so:
var foo = rowExt.Usrfield;

RowPersisted on two different DAC's are in infinite loop

I currently have custom RowPersisted events on SOLine and POLine in Acumatica. Basically I need to make sure that custom Vendor cost field in SO and unit price field in PO update each other for all the linked PO's and SO's, when user saves them in Acumatica. So I have something like this in POLine_RowPersisted:
soRecExt.UsrVendorCost = line.CuryUnitCost;
SOOrderEntry graph = PXGraph.CreateInstance<SOOrderEntry>();
graph.CurrentDocument.Current = soOrd;
var result = graph.Transactions.Select();
graph.Transactions.Update(soRec);
graph.Actions.PressSave();
And something like this in SOLine_RowPersisted:
poRec.CuryUnitCost = lineExt.UsrVendorCost;
POOrderEntry graph = PXGraph.CreateInstance<POOrderEntry>();
graph.CurrentDocument.Current = poOrd;
var result = graph.Transactions.Select();
graph.Transactions.Update(poRec);
graph.Actions.PressSave();
So unfortunately when one is updated the whole thing enters infinite loop. I have tried something like this:
POOrderEntry_Extension graphExt = graph.GetExtension<POOrderEntry_Extension>();
graphExt.RowPersisted.RemoveHandler<SOOrderEntry_Extension>(graphExt.POLine_RowPersisted);
However, there is no RowPersisted on graph extension. My events are set to public. Can someone help please?
The events are registered and triggered by the Base graph so you have to remove them on base graph.
I believe what you're trying to accomplish is more along the lines of:
POOrderEntry_Extension graphExt = graph.GetExtension<POOrderEntry_Extension>();
graphExt.Base.RowPersisted.RemoveHandler<POOrderEntry>(graphExt.POLine_RowPersisted);
Where 'graph' is of type POOrderEntry then using 'graph' is equivalent to 'graphExt.Base'.

Update relation at runtime

I need help in order to update relation at runtime.
I have this use case:
I have created a graph with the following collections:
- A (VertexCollection)
- B (VertexCollection)
- E (EdgeCollection) with relation( A -> B)
at runtme, using Foxx app, I neet to create a new collection (VertexCollection C) and I need to update EdgeCollection with the following relation( A -> [B,C]).
Is there a way to update relation at runtime?
Thanks in advanced,
Peter
You create new collections from Foxx with
var db = require("internal").db;
var C = db._create("C");
An edge collection E can contain edges with in arbitrary vertex collections, you create a new edge in E with:
var edge = E.insert("A/xyz", "C/abc", {"someData":12});
to create an edge from the vertex with _key "xyz" in A to the vertex with _key "abc" in C, say.
Does this answer your question?
In the ArangoDB manual, in section Modify a graph definition during runtime, the following ways for modifying edge definitions at runtime are shown:
Adding a new edge definition to an existing graph:
/* load graph module */
var graph_module = require("org/arangodb/general-graph");
/* load existing graph by name */
var graph = graph_module._graph("myGraph");
/* add a relation for edge collection myEC2, with vertices
between collections myVC1 and myVC3 */
var defs = graph_module._relation("myEC2", ["myVC1"], ["myVC3"]);
/* update the existing graph's definition */
graph._extendEdgeDefinitions(defs);
Modifying an existing edge definition in an existing graph:
/* load graph module */
var graph_module = require("org/arangodb/general-graph");
/* load existing graph by name */
var graph = graph_module._graph("myGraph");
/* update the relation for edge collection myEC2, with vertices
between collections myVC23 and [ myVC42, myVC99 ] */
var defs = graph_module._relation("myEC2", ["myVC23"], ["myVC42", "myVC99"]);
/* update the existing graph's definition */
graph._editEdgeDefinitions(defs);

Create SharePoint variation labels using CSOM

Can anyone tell me how to create SharePoint 2013 variation labels using client-side object model (CSOM). I know it is possible using SSOM and Powershell.
How to create Variation Labels in SharePoint 2013/Online via CSOM
VariationsClient class is intended for managing Variation Labels in SharePoint 2013.
The following operations are currently supported:
VariationsClient.CreateLabel method is used for create Variation Label
VariationsClient.GetLabelsList method gets Variation Labels on site
Usage
var variationsClient = new VariationsClient(ctx);
var siteLanguages = new[] {"en-US","ru-RU","fi-FI","nl-NL"};
foreach (var language in siteLanguages)
{
var isSource = (language == "en-US");
variationsClient.CreateLabel(new CultureInfo(language), isSource);
}
Result

GXT Grid with multiple sources

I am trying to create a grid using GXT that contains data from multiple JSON sources. I've been able to get the grid working with one source, but can't figure out how to add additional sources to the grid or the ListStore.
// ...
ScriptTagProxy<PagingLoadResult<ModelData>> proxy =
new ScriptTagProxy<PagingLoadResult<ModelData>>(url);
ModelType type = new ModelType();
type.setRoot("root");
type.addField("source");
type.addField("description");
JsonPagingLoadResultReader<PagingLoadResult<ModelData>> reader =
new JsonPagingLoadResultReader<PagingLoadResult<ModelData>>(type);
final PagingLoader<PagingLoadResult<ModelData>> loader =
new BasePagingLoader<PagingLoadResult<ModelData>>(proxy, reader);
ListStore<ModelData> store = new ListStore<ModelData>(loader);
final Grid<ModelData> grid = new Grid<ModelData>(store, cm);
add(grid);
// ...
Is there a way to add additional loaders to a GXT ListStore? Ideas? Thanks in advance.
It looks like one method of populating a grid with multiple remote sources is to use borrow from the article http://code.google.com/webtoolkit/articles/using_gwt_for_json_mashups.html and create a 'mashup' class that populates a ListStore with the results as each response is returned.

Resources