How to set minutes to a schedule reporting task in pega - pega

I want to set time for the
Time of Day
in schedule reporting task to 10.30.But we can set only hours in the pega UI.
can anyone help me with setting time with minutes.
Thanks.

Not out of the box. You would need to change a property named pyMinimumDateTimeForProcessing, and that can be done using a Data Transform (or an Activity). Here's an excellent summary how scheduled reports work: https://myknowpega.com/2019/12/12/schedule-reports-pega/. You can see where aforementioned property resides at the following heading:
Pega creates a new queue instance for the agent

pyScheduleTaskInfo is the Flow Action which is called on schedule report. Which is not a Final rule. That means you can modify this flow action.
If you look into 16th step of post processing Activity pzPostProcess(a 'Final' activity), you will find below lines.
int hour = myStepPage.getInteger(".pyTimeOfDay");
int minute= myStepPage.getInteger(".pyMinuteOfHour");
int second = myStepPage.getInteger(".pySecondOfMinute");
But, in the flow action section pyTaskScheduling, only pyTimeofDay is used. This is not a final section. Hence, you can save as it your ruleset.
pyMinuteOfHour and pySecondOfMinute are not used in the section. And these properties are no longer present in class Embed-ScheduledTask-Scheduling which is the primary class for section pyTaskScheduling. Hence you can not use these properties in section pyTaskScheduling .
You need to first save as section pyTaskScheduling(with same name and same class) in your ruleset.
Then add new properties just after hour dropdown to select minutes and seconds.
Save as activity pzPostProcess in your ruleset with other name and same class(since its final rule, name should be different) and modify below two lines of Java step 16.
int minute= myStepPage.getInteger(".pyMinuteOfHour"); // instead of pyMinuteofHour, add your property
int second = myStepPage.getInteger(".pySecondOfMinute"); // instead of pySecondOfMinute, add your property
Now save as flowaction pyScheduleTaskInfo in your ruleset(with same name and same class) and replace the post processing activity with your activity.
I have not tried this solution but you can try it.

Related

Call child form programmatically with parameter / filter

I'm creating a customization where on a click of a button, I need to allocate a charge for a particular purchase order / invoice journal.
From the front end, I would accomplish this by following the purchase order life-cycle and invoicing it. I would then go under the invoice tab of the PO, click Invoice Journals -> Charges -> Adjustment . This will open up my desired form where I will select a charges code, charges value, currency and category, and then I will click 'Ok' and have the system take care of the rest of the process.
Form name: MarkupAllocation_VendInvoiceTrans
Parent form Name: VendInvoiceJournal
You can see that the child form gets called with a few parameters such as the invoice number, there obviously needs to be that link. If I go into the AOT under forms, I right click and open up VendInvoiceJournal, but I wouldn't be able to open up MarkupAllocation_VendInvoiceTrans because it requires parameters.
Objective:
A: To open MarkupAllocation_VendInvoiceTrans through code where I manually pass those parameters to link to the parent table. I would provide the invoice number and such. The objective is to skip opening the parent table and manually going into the adjustments. I want to open that form directly and have it link to whichever record I specify.
B: I need to be able to pass a _ChargesValue parameter and have that be pre-populated for me. I don't know if this is possible, so I wanted to ask and confer. Ideally, I should be able to click a button on my custom form, and have MarkupAllocation_VendInvoiceTrans form directly open for a specified invoice, with pre-populated values on the line.
I know I should be tackling this problem one step at a time, so step A is priority number one.
I can open up the parent form with relative ease like so, but I cannot do the same for the child form. Obviously the same time of approach won't work, as I need to specify the relationship of the parent table before I open it.
private void allocateMarkup()
{
Object formRun;
Args args = new Args();
VendInvoiceJour jourTable;
;
select * from jourTable where jourTable.PurchId == 'PO000001191';
args.name(formstr(VendInvoiceJournal));
args.record(jourTable);
formRun = ClassFactory.formRunClass(args);
formRun.init();
formRun.run();
formRun.wait();
}
How would I be able to do so?
(Side note, I realize this whole form calling could be avoided if do all the transactions programmatically instead of letting the out of the box functionality handle it, but the markup and allocation logic is a beast of it's own and to me seems much more complicated than doing this. If someone has done it this manual way, any help on that would be greatly appreciated as well)
If I read your post right, you just want to open the Charges>Adjustment for a certain invoice. Here is one simple method:
MarkupAdjustment markupAdjustment = new MarkupAdjustment();
markupAdjustment.vendInvoiceJour(VendInvoiceJour::findFromPurchId('PO 120079'));
markupAdjustment.run();

session in class file

Hi I have a list called Event Source. In that am adding new item. Once i added , the background process takes this newly created id and start importing EventFields in the Specific List.In EventSource list item i have an ECB menu item called Sync and I should not click the Sync until the import completes in the EventField list. My Client not accepted creating a flag field in the "Event Source List". So wanna maintain some flag in session until the import finishes. for me oncei created EventSource and Clicked Sync first time the HttpContex.current is null but next time it is not.But i need to maintain the flag very first time. That import code is written in the class library.How to maintain.If i use static it s cleaing the value or another instances.,
You may be wording wrong your question but a Windows Service doesn't have an HttpContext, you simply can't do that.

How to determine next activity assignee in workflow in tridion

I am writing eventhandler for determining the workflow activities. I am able to get the currrent activity assignee.
I need to get the next activity assignee(i.e to which group the activity is assigned to).
Inside the TridionActivityDefinitinData for NextActivityDefinitions i find only Title and Idref of the activities.
Please let me know how to find the next possible activities' assignee.
Have a look at this question How to get the Next Activity Details from the FinishActivityEvent Hanlder?, where user978511 answered it there better than I can.
From what I see there, you'll need something like this:
FinishActivityEventArgs.ActivityFinish.NextAssignee
If that is indeed the case, I marked your question as a duplicate from that one.
Hope this helps someone...
Read the Process Definition for the full list of activities:
ProcessDefinitionData pdd = CoreServiceClient.Read(ProcessInstance.ProcessDefinition.IdRef, null) as ProcessDefinitionData;
then you can use your current posostion (not zero based) to index out from the Activitiy Definitions (zero based):
pdd.ActivityDefinitions[(int)ActivityInstance.Position].Assignee.Title
The above will get you the next activity information. If you want previous activities start by subtracting two from the current position and indexing from the Process Instance Activities:
ProcessInstance.Activities[(int)ActivityInstance.Position - 2].FinishMessage
Enjoy

How to get the Next Activity Details from the FinishActivityEvent Hanlder?

I have subscribed WorkflowFinishActivityEvent with TransactionCommitted phase. I am getting the details of the current finished activity like below
Performer of the current finished activity
foreach(var performer in currentactivity.Performers)
{
string Performeroftheactivity= performer .title.tostring();
}
Finish Message of the current finished activity
string finishmessage = currentactivity.FinishMessage.Tostring()
My Question:
I would like to take the Next assigned activity title and assignee from the current finished activity event.
Could anyone help me how to get these? I don’t see any relevant Properties or methods in the API.
You can get the next activity by loading the current process definition, determining the position of the current activity, and figuring out what's next.
This is more or less shown in this post by Mihai Cadariu.
EDIT - Removed silly comment about this not being supported. Since you're in an event system, that code will work. If you want to use it in a Workflow automatic activity then you would have to use the CoreService.
You have next assignee on FinishActivityEventArgs.ActivityFinish.NextAssignee. As for next activity - there's no way to know it for the moment. Consider subscribing to activity instance save event args. This way you will catch what activity was created and who is the assignee.

How to assign Custom Activity Result to a Root level variable at Runtime (in Custom Activity Execute method) in workflow?

Assume that I have a workflow with 3 Custom Activities which are placed in a Sequence Activity. And I created a Boolean variable (name it as “FinalResult”) at Sequence Activity level (Root) to hold the Result. My Intention is, I want to assign each Custom Activity Result to Root level variable (“FinalResult”) within the Custom Activity Execute method after finishing the activity.
I can get this by declaring the output argument in Custom Activity and placing the variable name at design time in the properties window of activity manually while designing the policy.
But I don’t want to do this by the end user. I want just the end user drag and drop the activities and write conditions on the” FinalResult” variable. Internally I have to maintain the Activity Result in “FinalResult” Variable through programmatically.
Finally I want to maintain the workflow state in “FinalResult” variable and access it anytime and anywhere in the workflow.
I tried like this below getting error "Property does not exist".
WorkflowDataContext dataContext = context.DataContext;
PropertyDescriptorCollection propertyDescriptorCollection = dataContext.GetProperties();
foreach (PropertyDescriptor propertyDesc in propertyDescriptorCollection)
{
if (propertyDesc.Name == "FinalResult")
{
object data = propertyDesc.GetValue(dataContext);// as WorkUnitSchema;
propertyDesc.SetValue(dataContext, "anil");
break;
}
}
Please let us know the possible solutions for the same.
I do this all the time.
Simply implement IActivityTemplateFactory in your activity. When dragged and dropped onto the design surface, the designer will determine if your activity (or whatever is being dropped) implements this interface. If it does, it will construct an instance and call the Create method.
Within this method you can 1) instantiate your Activity and 2) configure it. Part of configuring it is binding your Activities' properties to other Activities' arguments and/or variables within the workflow.
There are a few ways to do this. Most simply, require these arguments/variables have well known names. In this case, you can simply bind to them via
return new MyActivity
{
MyInArgument = new VisualBasicValue<object>(MyActivity.MyInArgumentDefaultName),
};
where MyActivity.MyInArgumentDefaultName is the name of the argument or variable you are binding to.
Alternatively, if that variable/argument is named by the user... you're in for a world of hurt. Essentially, you have to
Cast the DependencyObject target passed to the Create method to an ActivityDesigner
Get the ModelItem from that AD
Walk up the ModelItem tree until you find the argument/value of the proper type
Use its name to create your VisualBasicValue
Walking up the ModelItem tree is super duper hard. Its kind of like reflecting up an object graph, but worse. You can expect, if you must do this, that you'll have to fully learn how the ModelItem works, and do lots of debugging (write everything down--hell, video it) in order to see how you must travel up the graph, what types you encounter along the way, and how to get their "names" (hint--it often isn't the Name property on the ModelItem!). I've had to develop a lot of custom code to walk the ModelItem tree looking for args/vars in order to implement a drag-drop-forget user experience. Its not fun, and its not perfect. And I can't release that code, sorry.

Resources