How to enable a hyperlink in the form text control? - acumatica

I have a requirement to accept an URL on a text box and enable hyperlink on the control. Grid columns are allowing to enter a value and mark the column as hyperlink where it is not allowing to do on an editable text control. Is there a way to open the URL by clicking on the text control?

I have examined the Web entry control in Business account aspx source code and used PXLinkEdit Control for accepting the URL and allow to open the page. Even though it is not hyperlinking the text, it allows opening the URL through an action button, which is part of the control
<px:PXLinkEdit ID="edURL" runat="server" DataField="UsrURL" CommitChanges="True" />

Similarly, you could try a PXButton with optional ImageKey and navigate to your URL using Redirect4: (or Redirect0: if the URL is in same domain):
public PXAction<DAC> ViewOnWeb;
[PXUIField(DisplayName = "View On Web",
MapEnableRights = PXCacheRights.Select,
MapViewRights = PXCacheRights.Select)]
[PXButton(ImageKey = PX.Web.UI.Sprite.Main.World)]
protected virtual IEnumerable viewOnWeb;(PXAdapter adapter)
{
if (this.DAC.Current != null)
{
throw new PXException("Redirect4:" +
string.Format("http://my.site.com/search?Id={0}", DAC.code));
}
return adapter.Get();
}

Related

Hide a PXButton on a popup screen

I am trying to hide a PXButton on a popup screen
Here is my code:
protected void _(Events.RowSelected<POReceipt> e)
{
if (e.Row is null) return;
ActionMoveAll.SetEnabled(e.Row.ReceiptType == POReceiptType.TransferReceipt);
ActionMoveAll.SetVisible(e.Row.ReceiptType == POReceiptType.TransferReceipt);
}
<px:PXButton runat="server" ID="btnfillwithall" CommandName="actionMoveAll" CommandSourceID="ds" />
I have set AutoRepaint="true" and autoreload="true" and loadOnDemand="true" all to no luck. When the PXButton hits the server I do get a popup saying "the FillWithAll action is disabled", but I would like for it just to be removed entirely from the popup instead of just getting an error response.
You should not do ActionMoveAll.SetVisible() in the primary DAC RowSelected event handler _(Events.RowSelected<POReceipt> e). You should move ActionMoveAll.SetVisible(e.Row.ReceiptType == POReceiptType.TransferReceipt) to your popup window DAC RowSelected event handler. In your case it might be like _(Events.RowSelected<POReceiptLineAllocation> e)
Add SyncVisible="" to your PXButton as well. Set it to True (or False if True doesn't work, and check the result. One setting should work)

How do I force user input to commit and save automatically when executing an action?

I have a custom graph, in this case called MyGraph. The page contains a Form Tab in a similar fashion to the Stocked Items page in which the header is a few fields of my DAC (MyDAC), and a form on the 1st tab is a form of my additional fields. The views, for the sake of discussion, are MyView and MyCurrentView.
On the Stocked Items page, I can set a value in the ItemSettings view (General Settings tab) and then execute an action which also happens to save my user input. In my custom page, the user input of the similar "MyCurrentView" tab is lost when I execute an action. I have reviewed the training material once again for T230 Actions, but I cannot seem to overcome this problem. The code sample below shows 2 simplified methods of how I execute the action "ConvertIt". In both cases during a Debug, both myDAC and myDAC2 contain the stale data, indicating that the view was not updated as expected per CommitChanges in the Button attribute and in the DataSource Callback Command. The user input that is not saved is entered via a field presented to the UI only in MyCurrentView.
The T230 training guide indicates that I should set the AutoCallBack Behavior in the action bar, which appears to be possible for a grid, but not for a form. The example from the training guide is:
<ActionBar>
<CustomItems>
<px:PXToolBarButton Text="Complete">
<AutoCallBack Command="Complete" Target="ds">
<Behavior CommitChanges="True" ></Behavior>
</AutoCallBack>
</px:PXToolBarButton>
</CustomItems>
</ActionBar>
Since I am hanging my action off the Action menu via action.AddMenuAction(convertIt);, I do not seem to have a way to specify the behavior as described in the training guide.
Views Defined
public PXSelect<MyDAC> MyView;
public PXSelect<MyDAC, Where<MyDAC.tagID, Equal<Current<MyDAC.tagID>>>> MyCurrentView;
Action Defined - Method 1
#region convertIt Action
public PXAction<MyDAC> convertIt;
[PXUIField(DisplayName = "My DAC Label", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Select)]
[PXButton(CommitChanges = true)]
public virtual void ConvertIt()
{
this.Save.Press(); // Seems to make no difference in saving the unsaved user entry
MyDAC myDAC = MyView.Current;
MyDAC myDAC2 = MyCurrentView.Current;
** DO THE WORK OF THE ACTION HERE **
}
#endregion
Action Defined - Method 2
#region convertIt Action
public PXAction<MyDAC> convertIt;
[PXUIField(DisplayName = "My DAC Label", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Select)]
[PXButton(CommitChanges = true)]
public virtual IEnumerable ConvertIt(PXAdapter adapter)
{
MyDAC myDAC = MyView.Current;
MyDAC myDAC2 = MyCurrentView.Current;
** DO THE WORK OF THE ACTION HERE **
return adapter.Get();
}
#endregion
ASPX Datasource Defined
<px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%"
TypeName="MyGraph"
PrimaryView="MyView">
<CallbackCommands>
<px:PXDSCallbackCommand CommitChanges="True" Name="ConvertIt" ></px:PXDSCallbackCommand>
</CallbackCommands>
</px:PXDataSource>
In short, user input is lost when I complete my action. I have tried including this.Save.Press() at the beginning of my action, but I already save at the end of my action. Regardless, a Debug does not show my user entered values in the view, although I expected the commit changes on the button and in the data source to commit those changes from the client before proceeding with the action.
What have I left out of the C# code or ASPX page definition that is preventing my UI updates to be applied? Interestingly enough, UI changes in the MyView view ARE applied, but not changes in MyCurrentView unless I literally press the save button manually before selecting the action from the menu.
I ran into this problem recently as well. It’s easy to force the page to post back to server when opening a smart panel off of an action, but if there is no panel opening how do you force a post of data that was changed in fields that don’t commit on update?
The only way I’ve found to accomplish this is by editing the ASPX and adding StartNewGroup="true" and CommitChanges="true" to the PXDSCallbackCommand for the Action Folder that the action is added to.
<px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%"
TypeName="MyGraph"
PrimaryView="MyView">
<CallbackCommands>
<px:PXDSCallbackCommand CommitChanges="True" Name="ActionFolder" StartNewGroup="True" />
</CallbackCommands>
</px:PXDataSource>
For the action, you should use the second method.
public PXAction<MyDAC> convertIt;
[PXUIField(DisplayName = "My DAC Label", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Select)]
[PXButton(CommitChanges = true)]
public virtual IEnumerable ConvertIt(PXAdapter adapter)
{
MyDAC myDAC = MyView.Current;
MyDAC myDAC2 = MyCurrentView.Current;
**DO THE WORK OF THE ACTION HERE **
return adapter.Get();
}
public MyGraph()
{
actionFolder.AddMenuAction(convertIt);
}
It is not possible to save the focused field value. Value is saved when the control lose focus. However when the focus goes from an uncommitted field to an action button (clicked by user) the current field value is lost. Not sure this is the issue here but keep in mind that the user has to tab out of a control editor with uncommitted value before clicking on an action button or else the value is lost.

How come PXUIField attribute disables text edit boxes on a processing page in 2019 R1?

I'm trying to setup a processing page that will update a SOShipment document lines with new data entered on the PXFilteredProcessing page. When declaring a PXString (virtual field), if I add the PXUIfield attribute, the field becomes read only.
Here is the DAC declaration showing the actual problem. The page I use is a simple PXFilteredProcessing page with a completely custom page that was made in Visual Studio.
#region StockRow
public abstract class stockRow : IBqlField { }
[PXString()]
[PXUIField(Enabled = true)]
public virtual String StockRow { get; set; }
#endregion
#region StockFlag
public abstract class stockFlag : IBqlField { }
[PXString]
public virtual String StockFlag { get; set; }
#endregion
The page has the fields defined as follow :
<px:PXTextEdit ID="edStockRow" runat="server"
DataField="StockRow" Enabled ="true" >
</px:PXTextEdit>
<px:PXTextEdit ID="edStockFlag" runat="server"
DataField="StockFlag" Enabled ="true">
</px:PXTextEdit>
<px:PXGridColumn DataField="StockRow" Width="200px" >
</px:PXGridColumn>
<px:PXGridColumn DataField="StockFlag" Width="200px">
</px:PXGridColumn>
Should the PXUIField really make the field become read only or is there something I am not getting?
PS: I know I can re-enable the field on the RowSelected even, I'm mostly looking for an explanation as to why this is happening.
if I add the PXUIfield attribute, the field becomes read only
Are you sure that this is the operation making the field read-only?
Typically all processing screen detail fields are disabled except the Selected column. I believe this is a behavior introduced by the use of PXProcessing type data view. Going against that behavior will likely not yield the desired result.
If the screen needs detail fields to be editable (except Selected column) I would advise not to create a processing screen. Using a PXSelect data view instead will provide correct behavior for the editable fields.

Acumatica - NonStockItem Screen on AlloAddNew in Page

Good Day!
I have a PXSelector field in DAC that only show non-stock items
public abstract class inventoryID : IBqlField { }
[PXDBInt]
[PXSelector(typeof(Search2<InventoryItem.inventoryID,
LeftJoin<RECOInventoryItem, On<RECOInventoryItem.inventoryID, Equal<InventoryItem.inventoryID>>>,
Where<RECOInventoryItem.inventoryID, IsNull,
And<InventoryItem.itemType, Equal<ItemType.NON_STOCK>,
And<InventoryItem.stkItem, Equal<False>>>>>),
typeof(InventoryItem.inventoryCD),
typeof(InventoryItem.descr),
DescriptionField = typeof(InventoryItem.descr))]
[PXUIField(DisplayName = "Inventory")]
[PXDefault(PersistingCheck = PXPersistingCheck.Nothing)]
public virtual int? InventoryID { get; set; }
I also have a selector in my page that allows edit and allows add new methods
<px:PXSelector ID="edInventoryID" runat="server" DataField="InventoryID" AllowEdit="true" AllowAddNew="true">
</px:PXSelector>
Now, my problem lies with the edit(pencil) button in the User Interface. When I'm clicking the edit button, with the item that i want to edit, I am being redirected to Non-Stock Items page,
But when I want to add another Non-stock Item by using the edit(pencil) button, I am redirected to the Stock Items page.
I already set my PrimaryGraph.
[PXPrimaryGraph(typeof(PropertyMaint))]
public class RECOInventoryItem : Audit, IBqlTable
How do you set the AllowAddNew redirect to Non-Stock Item Page instead of the Stock Item Page.
How do you override the PxPrimaryGraph of the InventoryItem so that the graph that i'm redirecting to is Non-stock Item, instead of Stock Item.
Thank you so much for the advice and suggestions.
PXPrimaryGraph can handle binding 1 DAC to multiple graphs using BQL conditions on the DAC fields as shown on InventoryItem DAC:
[PXPrimaryGraph(new Type[]
{
typeof(NonStockItemMaint),
typeof(InventoryItemMaint)
},
new Type[]
{
typeof(Where<InventoryItem.stkItem, Equal<False>>),
typeof(Where<InventoryItem.stkItem, Equal<True>>)
})]
This works well with AllowEdit functionality because the InventoryItem.stkItem field used for the graph redirection is already populated in the record you want to edit.
When you create a new record with AllowAddNew though I suspect the field InventoryItem.stkItem will be null or always defaulted to the same value by PXDefault attribute. This would have the side effect of always redirecting to the same graph.
As you can probably guess AllowAddNew doesn't have any options or programmatic interface to influence it's behavior so it is pretty limited in what it can do. For that reason I don't think you can override it's behavior.
This leave creating your own action button as the only option I know to achieve your use case. You can style the button to show a + icon and no text like AllowAddNew does. You would still be limited on where you can place that button because Selector popup windows also lack options and programmatic interface.

wpf -shorcut key for image button

On my wpf window, I have got an image button. Does anyone have any idea how to assign a short cut for this button like "Cntrl + O".
I can put "_" to trigger click on normal button.
<Button Margin="89,73,114,106" Name="button1" Click="button1_Click">
<StackPanel Name="_StackPanel">
<Image Source="image.png" ></Image>
</StackPanel>
</Button>
In WPF general keyboard shortcuts (unlike the special case of Alt access keys) aren't assigned to buttons, they are assigned to actions. When you want both a Button (or menu item, multiple buttons, etc.) and a key command for the same action you can use a single Command for both. For a custom RoutedCommand you can assign KeyGestures to fire the command:
public static RoutedCommand MyCommand { get; private set; }
static Window1()
{
MyCommand = new RoutedCommand("MyCommand", typeof(Window1), new InputGestureCollection { new KeyGesture(Key.O, ModifierKeys.Control) });
}
public Window1()
{
InitializeComponent();
CommandBindings.Add(new CommandBinding(MyCommand, (_, e) => MessageBox.Show("Command fired")));
}
And then also assign it as the Button's Command:
<Button Content="Click Me" Command="{x:Static local:Window1.MyCommand}"/>

Resources