Automate Release Action from my Graph Extension - acumatica

How can I automate the Release button from my Graph Extension, I've extended the JournalWithSubEntry graph. I added a journal voucher transaction via code, the only problem now is how do I release the transaction I've added. Below is my sample code, and it gives me the error
cannot be accessed with an instance reference; qualify it with a type name instead in file
List<GLDocBatch> list = new List<GLDocBatch>();
list.Add(newdoc);
PXLongOperation.StartOperation(this.Base, delegate() { this.Base.ReleaseBatch(list); });

As ReleaseBatch is static you should use JournalWithSubEntry.ReleaseBatch instead of Base.ReleaseBatch.

Related

How can I invoke a task module on handleTeamsMessagingExtensionSelectItem(...)?

I am building a messaging extension app for MS Teams using the Teams-Toolkit in Visual Studio Code. I have been able to launch task modules from the message context without a problem but is there a way to launch a task module from handleTeamsMessagingExtensionSelectItem(context, obj)? The goal is for the user to select an item from the query list which triggers a new task module where they can fill out and submit a form (adaptive card).
For more visibility, adding the answer from the comment section:
Task module can be opened using TaskModuleResponse return type.
Only TeamsTaskModuleFetchAsync() method supports TaskModuleResponse return type.
TeamsMessagingExtensionSelectItemAsync() method return type can be MessagingExtensionResponse only. As this response type can't be changed.
So, overall not feasible.

Is that possible to retrieve products without passing catalogType?

I have a requirement to get products by code without knowing catalogType. Is that possible to retrieve products without passing catalogType?
Below is the code snippet I've tried:
#Resource
private ProductDao productDao;
#Resource
private CatalogVersionService catalogVersionService;
List<ProductModel> getProductsByCode(String code) {
CatalogVersionModel catalogVersionModel = new CatalogVersionModel();
catalogVersionModel.setVersion("Online");
catalogVersionService.addSessionCatalogVersion(catalogVersionModel);
List<ProductModel> productModels = productDao.findProductsByCode(code);
}
Below is the exception am getting:
{
"errors": [
{
"message": "model CatalogVersionModel (<unsaved>) cannot be serialized due to being modified, new or removed",
"type": "FlexibleSearchError"
}
]
}
May I know how to fix for above issue?
When you create a product/variant in SAP Commerce (hybris) you must attach it to a catalog.
A catalog (CatalogModel) also have a version (usually staged or online), and the object is called a CatalogVersionModel
When you want to retrieve a product/variant, you must indicate the CatalogVersionModel because the product code is not a unique key to retrieve the product in the DB (you can check the Type "Product" in the backoffice and see in the XML pane that both code and catalogVersion have the value unique="true")
Now in you code there are several issue.
You should not create a catalog version but you should retrive it using a service (See DefaultCatalogVersionService)
You should use a service to retrieve your product (See DefaultProductService)
In productService implementation, you'll find two methods getProductForCode.
One with only the sku code as parameter
One with the sku code and catalogVersion as parameter
The first method actually looks like the method you want, but in fact, it uses the catalogVersion in your session. Your session will be different if you run your code in groovy or if you run your code in Java from your ecommerce website.
You can find the comment of this method below
Returns the Product with the specified code. As default the search uses the current session user, the currentsession language and the current active catalog versions (which are stored at the session in the attribute SESSION_CATALOG_VERSIONS).For modifying the search session context see FlexibleSearchQuery.
You need to specify the catalog, because it is possible to have multiple catalogs, and the same product could exist in all of those catalogs.

Kentico 11 - duplicate object is created after rollback

After I added versioning to a custom class (see https://devnet.kentico.com/articles/module-development-versioning-recycle-bin), the duplicated object is created (instead of just updating the existing one) when rollback feature is used.
Since I was asked for the exact steps that I took, here they are:
I have a custom class which is called StoreInfo. It contains a set of fields as Name, Address, Country, etc.
For enabling versioning, I added the following changes to the generated code:
public class StoreInfo : AbstractInfo<IndustryInfo>
{
...
public static ObjectTypeInfo TYPEINFO = new ObjectTypeInfo(...)
{
...
SupportsVersioning = true
};
...
protected override bool VersioningEnabled
{
get
{
return SettingsKeyInfoProvider.GetBoolValue("CMSEnableObjectsVersioning");
}
}
}
After this change was applied the Versions tab appeared in the UI interface:
Then I changed the name of the store from Test name to Test name 1, so Version 1.1 was added to the versions list:
The issue happened when I clicked this button:
Instead of updating the name of the existing Store back from Store name 1 to Store name it created a new store with the data of Version 1.0:
Any thoughts about why this happens would be helpful.
Kentico version is 11. (dev. approach - portal engine)
If you deleted Object 1 and then created a "new" Object 1 and tried to roll back the deletion of the original Object 1, it will create a new one because they don't have the same attributes, especially the GUID.
So you may need to specify exactly the steps you took when you deleted the object, what you did after you deleted the object and what you did when you rolled back the original object.

Service Fabric - Stateful Service Persistence

I am new to service fabric and started by looking at the MSDN articles covering the topic. I began by implementing the Hello World sample here.
I changed their original RunAsync implementation to:
var myDictionary = await this.StateManager.GetOrAddAsync<IReliableDictionary<int, DataObject>>("myDictionary");
while (!cancellationToken.IsCancellationRequested)
{
DataObject dataObject;
using (var tx = this.StateManager.CreateTransaction())
{
var result = await myDictionary.TryGetValueAsync(tx, 1);
if (result.HasValue)
dataObject = result.Value;
else
dataObject = new DataObject();
//
dataObject.UpdateDate = DateTime.Now;
//
//ServiceEventSource.Current.ServiceMessage(
// this,
// "Current Counter Value: {0}",
// result.HasValue ? result.Value.ToString() : "Value does not exist.");
await myDictionary.AddOrUpdateAsync(tx, 1, dataObject, ((k, o) => dataObject));
await tx.CommitAsync();
}
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
}
I also introduced a DataObject type and have exposed an UpdateDate property on that type.
[DataContract(Namespace = "http://www.contoso.com")]
public class DataObject
{
[DataMember]
public DateTime UpdateDate { get; set; }
}
When I run the app (F5 in visual studio 2015), a dataObject instance (keyed as 1) is not found in the dictionary so I create one, set UpdateDate, add it to the dictionary and commit the transaction. During the next loop, it finds the dataObject (keyed as 1) and sets UpdateDate, updates the object in the dictionary and commits the transaction. Perfect.
Here's my question. When I stop and restart the service project (F5 in visual studio 2015) I would expect that on my first iteration of the RunAsync that the dataObject (keyed as 1) would be found but it's not. I would expect all state to be flushed to its replica.
Do I have to do anything for the stateful service to flush its internal state to its primary replica?
From what I've read, it makes it sound as though all of this is handled by service fabric and that calling commit (on the transaction) is sufficient. If I locate the primary replica (in Service Fabric Explorer->Application View) I can see that the RemoteReplicator_xxx LastACKProcessedTimeUTC is updated once I commit the transaction (when stepping through).
Any help is greatly appreciated.
Thank you!
-Mark
This is a function of the default local development experience in Visual Studio. If you watch the Output window closely after hitting F5 you'll see a message like this:
The deployment script detects that there's an existing app of the same type and version already registered, so it removes it and deploys the new one. In doing that, the data associated with the old application is removed.
You have a couple of options to deal with this.
In production, you would perform an application upgrade to safely roll out the updated code while maintaining the state. But constantly updating your versions while doing quick iteration on your dev box can be tedious.
An alternative is to flip the project property "Preserve Data on Start" to "Yes". This will automatically bump all versions of the generated application package (without touching the versions in your source) and then perform an app upgrade on your behalf.
Note that because of some of the system checks inherent in the upgrade path, this deployment option is likely to be a bit slower than the default remove-and-replace. However, when you factor in the time it takes to recreate the test data, it's often a wash.
You need to think of a ReliableDictionary as holding collections of objects as opposed to a collection of references. That is, when you add an “object” to the dictionary, you must think that you are handing the object off completely; and you must not alter this object’s state in the anymore. When you ask ReliableDictionary for an “object”, it gives you back a reference to its internal object. The reference is returned for performance reasons and you are free to READ the object’s state. (It would be great if the CLR supported read-only objects but it doesn't.) However, you MUST NOT MODIFY the object’s state (or call any methods that would modify the object’s state) as you would be modifying the internal data structures of the dictionary corrupting its state.
To modify the object’s state, you MUST make a copy of the object pointed to by the returned reference. You can do this by serializing/deserializing the object or by some other means (such as creating a whole new object and copying the old state to the new object). Then, you write the NEW OBJECT into the dictionary. In a future version of Service Fabric, We intend to improve ReliableDictionary’s APIs to make this required pattern of use more discoverable.

How to run technical rule in IBM ODM

I would like to know, how should we execute the rules written in technical rule of IBM ODM.
I am using ODM V8.0.1. I have tried as below.
I created a XOM having class named Courier.java
public class Courier {
private String courierType;
private int distance;
with getters & setters
}
I created a rule project adding this XOM and created respective BOM.
I have added Courier Object as IN_OUT ruleset parameter with Name as "courier"
Then created a Technical Rule with below code
when {
cour : Courier();
}
then {
note("Courier Object Check is Satisfied");
}
Created a ruleflow having only one rule task pointing the above technical rule.
Then I run this ruleflow as
Run as --> Run Configuration
In Run Configuration dailog box, written below function to create courier object and
ran the configuration.
com.seldart.Courier cour= new com.seldart.Courier();
return cour;
Ruleflow execution went for 2 seconds but the statement in note() method has not
printed in the console.
I am not sure, whether rule flow has not picked the technical rule itself to run or courier object is not recognized ? Kindly guide me on executing this technical rule in right way. Thanks.
I think you have to explicitly add your courier ruleset parameter to the working memory, for instance in the Initial Action of the Start Node of your ruleflow.
For example, in IRL:
insert courier;
Simply, first of all create an action verbalization for your function in B2X. This way, it becames "visible" to all rule objects in your project and references.
Second, try to create an action rule and reference this new verbalization with it.
Third, create a rule flow to orchestrate this action rule.
To execute all this stuff try to simulate the ruleset or export and run the jar package with the ILOG/IBM JRules API.

Resources