Acumatica Determine which button was clicked (Save or Complete) - acumatica

Activity screenshot
How can I determinate which button was clicked in Acumatica on the Activity screen (CR306010)?
I need to determinate on the Acumatica Activity screen which button was clicked: Save button, Save & Close or Complete.
I tried idea to use Acumatica PXContext.Session.SetString.
I overrided CRActivityMaint BLC and markAsCompleted() inside in order to set buttonclicked value for Complete button:
public delegate void markAsCompletedDelegate();
[PXOverride]
public void markAsCompleted(markAsCompletedDelegate baseMethod)
{
baseMethod();
PXContext.Session.SetString("buttonclicked", "Complete");
}
but I can't find a way to set for the same key (buttonclicked) value "Save" (when save button was clicked) and value "Save & Close" when Save & Close button was clicked.
I need to find a way somehow to set:
PXContext.Session.SetString("buttonclicked", "Save"); - for Save button;
PXContext.Session.SetString("buttonclicked", "Save & Close"); - for Save & Close button;
Is that possible in Acumatica to set it inside of some overeided method like:
**Pseudocode:**
public delegate void needToFindSaveDelegate();
[PXOverride]
public void needToFindSave()
{
baseMethod();
PXContext.Session.SetString("buttonclicked", "Save");
}
and:
**Pseudocode:**
public delegate void needToFindSave&CloseDelegate();
[PXOverride]
public void needToFindSave&Close()
{
baseMethod();
PXContext.Session.SetString("buttonclicked", "Save&Close");
}
I would be very thankful for any help how it can be accomplished.
Thanks in advance.
Have a nice day.

I have found out that Acumatica add the action name to the HttpRequest Parameters in the __CALLBACKPARAM parameter. So you can get which action has been called by checking it. You will need to add System.Web to your solution for being able to work with HttpContext.
string actionName =HttpContext.Current.Request.Params["__CALLBACKPARAM"].Split('|')[0]
Below is screenshoot of the value in case of pressing save button on Sales Orders Page:
And here is case of the Save and Close press:

Related

How to customize the approval button on the Expense Claim screen

I am trying to customize the approve button and I can't find the right method to do it.
Could you tell me how I can manipulate that event.
Thanks in advance.
button to customize
Method
I looked around at the ExpenseClaimEntry, and the approval is added from the class ExpenceClaimApproval. You can browse the code through the Code Library in an extension Library under the folder App_Data\CodeRepository\PX.Objects\EP\ExpenseClaimEntry.cs. The derived type is declared in the Descriptor\Attribute.cs file. There is a StatusHandler you can set that is executed upon approval/denial.
I built this test graph and was able to break in the middle of the approval process:
public class ExpenseClaimEntry_Extension : PXGraphExtension<ExpenseClaimEntry>
{
public void CustomApprovalAction(EPExpenseClaim item)
{
//do something
}
public override void Initialize()
{
base.Initialize();
Base.Approval.StatusHandler += CustomApprovalAction;
}
}

How can I disable the Employee Timecard (EP406000) 'update' button

I've been able to disable the insert and delete buttons on the Employee Timecards screem (EP406000) - but the update button doesn't seem to care. Here's my code:
protected void TimecardFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
Base.create.SetEnabled(false);
Base.update.SetEnabled(false);
Base.delete.SetEnabled(false);
}
It works for the insert and delete - but not for the update. I noticed in the source code that the code for the update button is a little different in that it doesn't have a [PXUIField] attribute, along with a few others. The insert and delete buttons have a similar setup and attributes, but update is definitely different. Not sure if this is why.
Bottom line: How can I disable the update button on the Employee Timecard (EP406000) screen?
Your diagnostic that the Update action is missing the PXUIField attribute is spot on.
Some button properties functionality requires having a PXUIField attribute.:
You can redefine the Update action to add the PXUIField attribute:
using PX.Data;
namespace PX.Objects.EP
{
public class TimecardPrimary_Extension : PXGraphExtension<TimecardPrimary>
{
public PXAction<TimecardPrimary.TimecardFilter> update;
[PXButton(Tooltip = Messages.EditTimecardToolTip, ImageKey = PX.Web.UI.Sprite.Main.RecordEdit)]
[PXUIField]
protected virtual void Update()
{
EPTimeCard row = PXSelect<EPTimeCard, Where<EPTimeCard.timeCardCD, Equal<Current<TimecardWithTotals.timeCardCD>>>>.Select(Base);
if (row == null) return;
PXRedirectHelper.TryRedirect(Base, row, PXRedirectHelper.WindowMode.InlineWindow);
}
protected void TimecardFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
Base.create.SetEnabled(false);
Base.update.SetEnabled(false);
Base.delete.SetEnabled(false);
}
}
}
Adding the PXUIField attribute will make the SetEnabled method work:
If you double-click on a grid record it will invoke the Grid default action (update in this case).
When double-clicking the record it will notify the user that the action is disabled:
To prevent invoking a disabled default action, you can customize the grid action bar to remove the default action:

Adding a Customized Button to a Processing Page [Acumatica]

I am trying to customise an Acumatica Processing Page by adding my own processing button. I have tried the usual methods of extending the processing page but unfortunately the button is not displayed on the page.
public class APPrintChecks_Extension : PXGraphExtension<APPrintChecks>
{
public PXAction<APPayment> Test;
[PXProcessButton]
[PXUIField(DisplayName = "Button Test")]
protected virtual IEnumerable test(PXAdapter adapter)
{
return adapter.Get();
}
}
I do not want to override the existing functionality provided by the processing button and as such would like to add my own.
Thanks.
The primary view of the Process Payments / Print Checks page is Filter which is of type PrintChecksFilter. So you need to have your PXAction on that Type. Try to replace
public PXAction<APPayment> Test;
with
public PXAction<PrintChecksFilter> Test;

Keyboard is not shown up after came from android default contact page in my app

I have one button called "Invite Paricipants". When i tap on it, my app will goes to android default contact page. After selecting contact, i am calculating the emails in it. If i found no email then, showing edit text to enter email. There i am using following code
editText.setOnFocusChangeListener(new OnFocusChangeListener() {
#Override
public void onFocusChange(View v, boolean hasFocus) {
editText.post(new Runnable() {
#Override
public void run() {
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
}
});
}
});
editText.requestFocus();
but keyboard is not showing up. How can i resolve my problem?
Yes he is right, after coming back the focus to EditText has been lost and by using requestFocus for EditText allows you to have focus and obviously pops up the Keyboard
You have to request input focus for editText.
To do this go to your interface definition xml and add:
<requestFocus />
Inside the definition for editText.

How to close user control used in radgrid filtering?

I have a radgrid, for date column i have created a custom user control for filtering. I need to create a close button to close the user control. There are no close events which i can call. I don't want to make visibility collapsed. I started with something below:
public partial class DateFilterControl : UserControl, IFilteringControl
{
public event CloseEventHandler Close;
public delegate void CloseEventHandler();
private void Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
It is throwing nullreference exception which is obvious to come. What code do i need to put to close the user control?
use Messaging Service. With this you can close the window in ViewModel so no need to give close function in Backend. Add Command property to Cancel button
<Button Content="Cancel" Command="{Binding CancelCommand}"/>
Now in the ViewModel add the RelayCommand property in that add
Messenger.Default.Send<bool>(true, typeof(XViewModel));
Now in the BackEnd of this userControl adds following in the constructor.
Messenger.Default.Register<bool>(this, typeof(ScheduleViewModel), (b) =>
{
if (b == true)
{
this.DialogResult = true;
}
});
Now u can close the Window...
This will surely helps u...

Resources