Acumatica. Get ItemClass Attributes on Sales Order dialog box - attributes

I’m trying to get the Attributes per ItemClassId to place them on a grid in the look up dialog box (Sales Order Entry).
enter image description here
I’m using the CSAttributeGroupList method:
public PXFilter<SOSiteStatusFilter> ItemSearchClass;
{
[PXViewName("Attributes")]
CSAttributeGroupList<INItemClass, SOSiteStatusFilter> Attributes;
public PXFilter<SOSiteStatusFilter> ItemSearchClass;
[PXViewName("Attributes")]
CSAttributeGroupList<INItemClass, SOSiteStatusFilter> Attributes;
}
I can't find the proper way to bring the attributes from each ItemClassID.
I have tryed:
public CSAttributeGroupList<INItemClass, SOSiteStatusFilter> Attributes;
But it doesn't work either.

I would first put SyncPosition=True on the grid to the right, to ensure that the current inventory item is selected. From there, you would want to use the code that is found in InventoryItemMaintBase:
public CRAttributeList<InventoryItem> Answers;
This would pull the current inventory item's attributes, and should automatically link to the items answers. You may need to mess with getting the grid on the right to refresh after the row is selected for the inventory item, if it does not do it automatically.

Related

How to Save Filter values on processing page

I have a custom processing page that has 3 fields in the custom filter DAC. I want any values in these three filter fields to stay set after the user clicks Process or Process All. Right now, they are cleared out when the processing completes. How can I get them to keep their value?
The filter DAC is currently unbound - should I make it a real table in the DB?
Here are what the views look like now:
public PXFilter<POLineFilter> Filter;
[PXFilterable]
public PXFilteredProcessingJoin<POLine, POLineFilter,
InnerJoin<PMProject, On<PMProject.contractID, Equal<POLine.projectID>>>,
Where<POLine.closed.IsEqual<False>.And<POLine.cancelled.IsEqual<False>>
.And<POLine.projectID.IsEqual<POLineFilter.projectID.FromCurrent>.Or<POLineFilter.projectID.FromCurrent.IsNull>>
.And<POLine.orderNbr.IsEqual<POLineFilter.poNbr.FromCurrent>.Or<POLineFilter.poNbr.FromCurrent.IsNull>>
.And<PMProject.ownerID.IsEqual<POLineFilter.projectManager.FromCurrent>.Or<POLineFilter.projectManager.FromCurrent.IsNull>>>> POLines;
TIA!
Add the following as your 2nd view.
public PXCancel<POLineFilter> Cancel;

Limiting Projects based on selector

I would like to filter the records shown on the Projects screen. I've been given the directive to see if limiting the Selector for projects (re-writing the PXSelector for the ProjectID?) would also limit the records that show up on the screen, i.e., a user would not be able to navigate to records that aren't displayed by the Selector. I don't think that's the case, as the screen's view is not limited by what is chosen by the Selector - but I wanted to verify this.
Also - as far as limiting the records that show up in the Selector (possibly re-writing the Selector/BQL using a where clause?) - I looked at the source DAC, and for the life of me I can't figure it out. There is a PXSelector on the ContractID, which doesn't use the SubstituteKey that I'm familiar with, and the ContractCD also has several attributes with which I'm unfamiliar - namely the PXRestrictor AND the PXDimensionSelector.
Bottom line:
1.) What's the best way to limit the records for Project shown in the screen's Selector? Can I just add to the PXRestrictor attribute?
2.) Would limiting the Selector's results also limit what the user can navigate to on the screen using the navigation buttons?
Whenever you need to restrict access to primary records on a data entry screen, it's always required to customize both the lookup DAC key field and the primary data view. By design, in Acumatica key fields in DAC and the primary data view are completely independent, that is why it's required to modify both pieces to achieve the desired result.
For example, to deny access to canceled projects on the Projects screen, you should add PXRestrictorAttribute to PMProject's ContractCD field and also re-declare Project primary data view:
public class ProjectEntryExt : PXGraphExtension<ProjectEntry>
{
public class cancelled : Constant<string>
{
public cancelled() : base(ProjectStatus.Cancelled) {; }
}
[PXViewName(Messages.Project)]
public PXSelect<PMProject, Where<PMProject.baseType, Equal<PMProject.ProjectBaseType>,
And<PMProject.nonProject, Equal<False>, And<PMProject.isTemplate, Equal<False>,
And<PMProject.status, NotEqual<cancelled>,
And<Match<Current<AccessInfo.userName>>>>>>>> Project;
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXRestrictor(typeof(Where<PMProject.status, NotEqual<cancelled>>),
"Given Project/Contract '{0}' is cancelled", typeof(PMProject.contractCD))]
public void PMProject_ContractCD_CacheAttached(PXCache sender) { }
}

Attaching Documents to Custom Table Records without a Custom Screen

I have a custom table for historical data. It's a one-time data dump directly into SQL so I'd prefer not to have to create a screen for it.
I have three columns in my table:
CompanyID INT
InvoiceNbr NVARCHAR(40)
Amount DECIMAL(19,4)
I create a new Customization Project and added a new DAC to the Code area that is linked to my custom table:
https://i.imgur.com/6mNjdou.png (Screenshot #1)
https://i.imgur.com/IdNLJkR.png (Screenshot #2)
Then I create a Generic Inquiry, but I don't get the Paper Clip and Note icons. I was hoping to use the Paper Clip to upload documents and attach them to the records in my custom table.
So, I added another column to my custom table:
NoteID UNIQUEIDENTIFIER
And I re-added the new DAC which now generates this code:
https://i.imgur.com/QvpWB5X.png (Screenshot #3)
Now I get the Paper clip and Note icons in my Generic Inquiry:
https://i.imgur.com/olCglBB.png (Screenshot #4)
I can add a note or attach a document and the icons change color which makes it seem like the notes and documents got attached to the records. But when I refresh the page, everything goes away. Also, I can tell that nothing is getting stored in the database.
So the Paper Clip and Note icons don't work.
I'm wondering if it's possible to get the Paper Clip and Note icons to work in my Generic Inquiry without building a custom screen. Is this possible?
Tim, for Notes and Attachments to work properly, your NoteID field should be decorated with the PXNote attribute, instead of the default combination of PXDBGuid- and PXUIFieldAttribute. Will everything work as expected after you replace NoteID field declaration with the code snippet below and republish the customization?
public abstract class noteID : PX.Data.IBqlField
{
}
[PXNote()]
public virtual Guid? NoteID { get; set; }

XPages Dynamic View Panel - show columns as links

I am using a dynamic view panel along with a customizer bean (as demonstrated by Paul Calhoun on NotesIn9 back in episode 79 https://www.youtube.com/watch?v=AQOGgVZpAcw).
The customizer bean is currently very simple, just to ensure the documents are opened in read mode :-
public void afterCreateColumn(FacesContext context, int index,
ColumnDef colDef, IControl column) {
//Get a map of the session variables to read the view session scope variable
Map svals = context.getExternalContext().getSessionMap();
//Create a variable for the current component
UIComponent columnComponent = column.getComponent();
//Create a reference to the column and set the links to open in read mode
DynamicColumn dynamicColumn = (DynamicColumn) columnComponent;
//To have every view open the selected documents in read mode add the following
dynamicColumn.setOpenDocAsReadonly(true);
super.afterCreateColumn(context, index, colDef, column);
}
The dynamic view panel currently shows the first non-categorised column as a link to open the document. Can I add further customisation to show other columns as links, either instead of or as well as the first column?
Yes - you should be able to do this in a couple ways. The way I've done it in my customizer bean before is to handle it when fetching the column information at the front, since the goal of the bean is to match the view's design as closely as possible.
In your code there, though, you could also call dynamicColumn.setDisplayAs("link") or dynamicColumn.setDisplayAs("text") as appropriate to turn on or off link display.

JavaFX 2.0: What do I have to do to react on a row selection change in a table?

I want to do a very easy and common thing but don't find a way to do it with JavaFX.
I have a TableView with two columns and want to enable a button if at least one row is selected. If no row is selected I want to disable the button again.
For that I need to get a selection changed event or something like that. Shouldn't be there a possibility to set the selectionModel of the tableView on action or add a listener to it?
What do I have to do?
I think what you will want to do is add a ListChangeListener to the selected indices on the selection model of your TableView. It should go something like this...
tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); // just in case you didnt already set the selection model to multiple selection.
tableView.getSelectionModel().getSelectedIndices().addListener(new ListChangeListener<Integer>()
{
#Override
public void onChanged(Change<? extends Integer> change)
{
if (change.getList().size() >= 2)
{
button.setDisable(false);
}
else
{
button.setDisable(true);
}
}
});
I was originally going to suggest binding the disable property of the button to a selected indices property size on the table view being greater than 2, but there doesn't seem to be one provided. If you wanted to, you could create your own SimpleIntegerProperty and update it inside of the list change listener, binding the disable property of the button to the value of your SimpleIntegerProperty being greater than 2. I hope this answer is helpful!
An other solution in one line using the Property :
myButton.disableProperty().bind(myTable.getSelectionModel().selectedItemProperty().isNull());
That way, the button is enable when there is at least one line selected

Resources