Acumatica - Rename Referential Grid field - field

I want to rename a column from its Name in DAC at the place it is reference, the ID field is part of DAC while the Name field is reference by the main DAC using Table__Field in the Grid, How that can be renamed, I tried the Below code but it is not working for reference column "ABCOrder.Status" which is link with AMProdItem on ABCOrder.CodeID,
Note- rename worked for AMProdItem.StatusID but not for ABCOrder.status
public override void Initialize() {
PXUIFieldAttribute.SetDisplayName<ABCOrder.status>(Base.ProdOperRecords.Cache, "QCO Status");
PXUIFieldAttribute.SetDisplayName<AMProdItem.statusID>(Base.ProdOperRecords.Cache, "Order Status");
}

If I'm understanding your question correctly, then I've had a similiar issue. I had a view in a custom form that joined with SOORder. I needed to rename one of the fields from SOOrder in my grid. See my code below where I use the CacheAttached command. Interestingly, I found that if I didn't create a cache for SOORder with the view in the first line, the cache attached failed.
public PXSelect<SOOrder, Where<False>> SOorders;
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXCustomizeBaseAttribute(typeof(PXUIFieldAttribute), nameof(PXUIFieldAttribute.DisplayName), "Customer Order Nbr.")]
protected virtual void SOOrder_CustomerOrderNbr_CacheAttached(PXCache sender) { }

Related

How to delete tenant completely?

I'm developing a multitenant application and would like to have to option to remove a tenant. This however seems to be less trivial than one would assume.
My goal is to delete all references to the tenant everywhere in the database. I understand that Tenant is Soft-Delete, but I since I don't want my database to fill up with old meaningless data I've tried disabling the soft-delete filter.
Here is some code that I've tried:
using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.SoftDelete))
{
await TenantRepository.DeleteAsync(x => x.Id == tenantId);
}
This did not work. The tenant is marked as "IsDeleted" but not removed.
Then I figured that maybe it has something to do with UnitOfWork so I made sure no UnitOfWork was active and then manually controlled it:
using (var unitOfWork = _unitOfWorkManager.Begin())
{
// the codeblock above went here
unitOfWork.Complete();
}
This did not work, same result. And this is just the AbpTenant table. I'm also trying to delete from all other tables. For example AbpSettings and AbpLanguages. It's very unclear to me how to do that at all - the "managers" doesn't contain any Delete functions.
I tried creating IRepository for these entities but it does not work. The error reads
The type Abo.Configuration.Setting cannot be used as a type parameter TEntity in the generic type or method IRepository. There is no implicit reference conversion from Abp.Configuration.Setting to Abo.Domain.Entities.IEntity.
That leaves me with the option to use the DataContext directly:
using (EntityFramework.MyDbContext db = new EntityFramework.MyDbContext())
{
List<PermissionSetting> perms = await db.Permissions.Where(x => x.TenantId == tenantId).ToListAsync();
for (int i=0; i<perms.Count(); i++)
{
db.Permissions.Remove(perms[i]);
}
// I also tried deleting them in bulk at first
// ((DbSet<PermissionSetting>)db.Permissions).RemoveRange(db.Permissions.Where(x => x.TenantId == tenantId));
await db.SaveChangesAsync();
}
I tried that with and without UnitOfWork.
But it simply does not get deleted from the database. I'm getting no errors or Exceptions.
Why does it not get deleted? How can I delete it? Surely it must be possible?
since I don't want my database to fill up with old meaningless data I've tried disabling the soft-delete filter.
From the question on Disable SoftDelete for AbpUserRole:
protected override void CancelDeletionForSoftDelete(EntityEntry entry)
{
if (IsSoftDeleteFilterEnabled)
{
base.CancelDeletionForSoftDelete(entry);
}
}
The type Abo.Configuration.Setting cannot be used as a type parameter TEntity in the generic type or method IRepository. There is no implicit reference conversion from Abp.Configuration.Setting to Abo.Domain.Entities.IEntity.
Inject IRepository<Setting, long> instead of IRepository<Setting>.
That leaves me with the option to use the DataContext directly
...
But it simply does not get deleted from the database. I'm getting no errors or Exceptions.
From the documentation on Data Filters:
using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant))
{
using (var db = new ...)
{
// ...
}
}
That said, there is no way to easily delete related tenant data completely. Consider writing SQL.

Group arguments under a 'Custom' category in the TFS 2012 build template

I am working on TFS 2012 deployment build. I want to group arguments under a 'Custom' category in the build template as shown in the image below,
That is,
3. Custom
> Web
1. Source:
2. Target:
> Console
1. Source:
2. Target:
How to do it? Please let me know your suggestions.
Create a custom build process template as it is described in Customize your build process template. You've probably already done that.
Create a custom build activity DLL as it is described in Use and develop custom build process activities. Again, you've probably done that. We will add our custom build parameter classes to this assembly.
Add the parameter class. This class will hold your parameter values:
[BuildExtension(HostEnvironmentOption.All)]
[Serializable]
[TypeConverter(typeof(SourceTargetSettingsConverter))]
public class SourceTargetSettings
{
[DisplayName("1. Source")]
[Description("Description for Source")]
[Browsable(true)]
public string Source { get; set; }
[DisplayName("2. Target")]
[Description("Description for Target")]
[Browsable(true)]
public string Target { get; set; }
}
Add the type converter. The parameter editor will only display its contents if your class is attributed with an ExpandableObjectConverter or a class derived from that type:
public class SourceTargetSettingsConverter : ExpandableObjectConverter
{
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
return destinationType == typeof(string) || base.CanConvertTo(context, destinationType);
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
var parameters = (SourceTargetSettings) value;
if (destinationType == typeof (string))
{
return "This appears in the right column of the parameters editor.";
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
Add the parameters to your process. Build your custom assembly, add a reference to it in process template project, open your process template and add new arguments. Type them with your custom parameters class and create default values:
Add parameter metadata. As MrHinsh has stated in his answer, we still have to add a custom group. Look for Metadata in the arguments list and open the editor. Add two metadata items and refer to your process parameters:
Upload. Save your process template. Checkin both your custom assembly and your customized process template. Open the build process editor for a build process that uses your custom template, or reopen it.
If you open and edit your .xaml build template you should see a parameter pre-configured called "meta*". If you select it and click the ellipse that is presented you will get the options that you are looking for.

Object Id set as null when saving - AjaxDependencySelection

So I decided to use AjaxDependencySelection Plugin for Grails, and it has proven to be very useful. However, I am trying to implement autoComplete boxes, and it does not seem to be saving the object id when using an Autocompleted selection. Here is my implementation in my gsp
<g:selectPrimary id="template" name="template"
domain='dms.nexusglobal.Template'
searchField='templateName'
collectField='id'
domain2='dms.nexusglobal.Tag'
bindid="template.id"
searchField2='tagName'
collectField2='id'
hidden="hiddenNew"
noSelection="['': 'Please choose Template']"
setId="tag"
value="${documentPartInstance?.template}"/>
<g:selectSecondary id="tag" name="tag"
domain2='dms.nexusglobal.Subtag'
bindid="tag.id"
searchField2='subtagName'
collectField2='id'
autocomp="1"
noSelection="['': 'Please choose Tag']"
setId="subtag"
value="${documentPartInstance?.tag}"/>
<g:autoCompleteSecondary id="subtag" name="subtagId"
domain='dms.nexusglobal.Subtag'
primarybind='tag.id'
hidden='tag'
hidden2='hidden5'
searchField='subtagName'
collectField='id'
value='${documentPartInstance?.subtag}'/>
<input type=hidden id="hidden5" name="subtagId" value="${documentPartInstance?.subtag}"/>
However, everytime I save it, I am presented with this error Column 'subtag_id' cannot be null . Here is my domain class definition for Subtag
class Subtag {
static scaffold = true
String subtagName
static belongsTo = [tag : Tag]
public Subtag()
{
}
public Subtag(String s)
{
subtagName = s
}
static constraints = {
}
String toString(){
subtagName
}
}
Tag hasMany subtags as well
It seems to be creating new Subtag instances when using the autoselect box (as an error shows up saying Could not find matching constructor for:packagename.Subtag(java.lang.String) Although this is a feature I am looking to implement in my application at later stages (being able to create new Subtags on the fly when creating a document Part), right now, all I would like to be able to do is just choose from my already existing subtags.
When I add in a string constructor, it comes back with the error that Column subtag_id cannot be null
I have developed it so will try help you through your issue.
The problem is that you are trying to push a value from selectSecondary and update the elementId of g:autocomplete which is actually a seperate entity.
I will update the plugin with a new method, need to test it out first.. Also take a look at g:selectAutoComplete. Although this method would only work if your secondary was the primary task... so no good in that case either..
hang on and look out for 0.37 release
Released 0.37 documentation on how to do such a thing here: https://github.com/vahidhedayati/ajaxdependancyselection/wiki/from-selection-to-autocomplete---how-to

How to use the selected values from the s:inputtransferselect struts tag

I am unable to find the attribute which holds the selected value in the case of <s:inputtransferselect/> Struts Tag. I referred to the documentation but I'm still unable to figure out which attribute exactly holds the selected values.
In the case of <s:optiontransferselect/>, I was able to get the selected values from the doubleId attribute. I am looking for a similar attribute for <s:inputtransferselect/>.
Inputtransferselect creates an input field, a multi option select list and some buttons to add and remove from the select list. When you submit your form this triggers some javascript to select all of the options in the select list, these options then appear in the list on the java side.
Here is an example.
Your .jsp file:
<s:inputtransferselect
key="cartoonCharacters"
addLabel="Add element"
removeLabel="Remove element"
removeAllLabel="Remove all elements"
upLabel="Move up"
downLabel="Move down"
leftTitle="Add Character"
rightTitle="Existing Characters"
list="cartoonCharacters"
/>
Make sure that your .jsp includes a <s:head/> tag else the javascript required for the inputtransferselect to work won't be available to your page.
To see all available attribute parameters of this tag refer to the documentation.
Your action .java file should contain a list which corisponds to the key and list of your inputtransferselect. To get hold of the values, use the list's getter:
public abstract class MyAction extends AbstractAction
{
private List<String> cartoonCharacters = new ArrayList<>();
public MyAction()
{
cartoonCharacters.add("Popeye");
cartoonCharacters.add("Superman");
cartoonCharacters.add("Scoobydoo");
}
public List<String> getCartoonCharacters()
{
return this.cartoonCharacters;
}
public void setCartoonCharacters(List pCartoonCharacters)
{
this.cartoonCharacters = pCartoonCharacters;
}
public String execute() throws Exception
{
return SUCCESS;
}
}
I should also note that in my implementation I haven't got this to work properly - the javascript to automatically select all options on form submit isn't firing so I had to write my own event for this, it's probably something to do with my other on submit events clashing.

Vaadin - Disable Column reordering for particular column

I'm doing a project in Vaadin 7.
In my project, I need to disable column reordering feature for particular columns in Treetable?
I'm really searching for function like this 'setColumnReorderIds()'.
Is it possible to do it in Vaadin 7.
Or else I need to write some code with 'ColumnReorderListener()'?
Update
This code is to set the first column fixed in a TreeTable. I want to disable reordering in Hierarchy column in the tree table.
public class CustomTreeTable extends TreeTable {
private static final long serialVersionUID = 1L;
private Object[] visibleColumns;
private KeyMapper<Object> columnIdMap = new KeyMapper<Object>();
#Override
public void paintContent(PaintTarget target) throws PaintException {
super.paintContent(target);
paintColumnOrder(target);
}
private void paintColumnOrder(PaintTarget target) throws PaintException {
visibleColumns = this.getVisibleColumns();
final String[] colorder = new String[visibleColumns.length];
int i = 0;
colorder[i++] = columnIdMap.key("Column 1"); // Logic to keep the first column fixed
for (Object colId : visibleColumns) {
if(!colId.equals("Column 1")) {
colorder[i++] = columnIdMap.key(colId);
}
}
target.addVariable(this, "columnorder", colorder);
}
}
Update 2
I tried what Oskar said..
In addition to
paintColumnOrder(target).
I'm calling
paintVisibleColumnOrder(target),
paintAvailableColumns(target),
paintVisibleColumns(target).
i'm able to stop reordering only for the table headers. But, the body is still reordering. Any guesses on this issue?
In the documentation there is only setColumnReorderingAllowed() which allows to control reordering of all columns. So if your case is to control particular ones it looks to me as a very custom behaviour and I would go with own implementation. Also ColumnReorderEvent is generated after processing the action itself therefore implementing own ColumnReorederListener won't help us here I think.
All actual magic which we want to change happens in private Table.paintColumnOrder() called from public Table.paintContent(), called from public TreeTable.paintContent() (see sources of Table and TreeTable). The solution would be:
extend TreeTable
override paintContent() with merged copies of Table.paintContent() and TreeTable.paintContent()
replace paintColumnOrder() call with your custom logic.
Update
Ok, now I see it's more tricky then I thought at the beginnig, since there is no easy way to access most of required fields and methods after subclassing TreeTable... Moreover, columns are reorered on the client side and only the change event status is sent to inform the server. I don't know how to handle custom reordering without creating custom gwt widget :(

Resources