Is there a way to have a new PXDBDecimal field show null - acumatica

I have added PXDBDecimal user fields to an existing screen in the form section. When creating a new record, these immediately show as '0.00' - I'd like to know if there's a way for it to just show empty / null. I have no PXDefault attribute, so it's not set to default to 0.00.

See the answer here: (Presumably this is the same case with PXDBInt and PXDBDecimal)
Default [PXDBInt] data field to Null value?

Related

Acumatica: Getting value of field on header from grid event

I'm new to Acumatica custom development and I'm trying to do something that I would assume is very simple. I have a Selector control (DataClass: FSServiceOrder, DataField: BranchLocationID) in the Sales Order header that allows user to set the Branch Location. Below, in an Inventory grid, I merely want to set the Warehouse field in the new row equal to the value of the above-mentioned selector. I can set Warehouse with a hard-coded value, but I have no idea how to reference the selector or get it's value, as it seems to be outside the scope of the passed PXCache object:
protected void FSSODetPart_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
string BranchLocationID = "" // Not sure how to get this value
var row = (FSSODetPart)e.Row;
cache.SetValueExt(row, "SiteID", BranchLocationID);
}
I was hoping I could simply reference all UI controls similar to ASP.NET, but that doesn't seem to be the case. Any help is appreciated. Getting a value from the screen seems to be fundamental but I cannot find any help in the documentation. Thanks.
In Acumatica screen controls are bound to DataViews.
DataViews contains DAC records. Common practice is to get the value from the current DAC record in the bound DataView.
Use the current object of the DataView holding FSServiceOrder DAC records:
string BranchLocationID = myDataview.Current.BranchLocationID;
If you don't know the DataView name, on the WebSite hold Ctl+Alt and click on the BranchLocationID UI field. A popup will appear showing the DataView name.
Getting the current object from the DAC collections should work too but it's preferable to use the DataView:
string BranchLocationID = Base.Caches[typeof(FSServiceOrder)].Current.BranchLocationID;
Also make sure you set the CommitChanges attribute to true on BranchLocationID form field in the Aspx file. This ensures that current object will fire events in the back-end when it's value is changed.
<px:PXSelector ID="edBranchLocationID" runat="server"
DataField="BranchLocationID" CommitChanges="True" />

Refresh edit box after information change

I have edit box which has validation- it is required field and it has range of values validation as well. The validation works ok, but the problem is that error message does not dissapear when I replace the values in edit box with valid ones. I tried to add full update on onchange event but this is not a option for me since this changes other fields in my xpage as well. The partial update on the field does not work. Any advice how to refresh the field so that error message dissapears?
Create a wrapper panel or div around BOTH the field and the error message control and set it's ID to the one that should be partially refreshed. I assume you use
XSP.partialRefreshGet("#{id:idOfYourField}")
in the onblur client event!? So just change the ID name here.

java.util.ArrayList incompatible with [Ljava.lang.Object check box group

I have a Check box group, whose values are computed by using the selected values of another Check box group. So when I do
var check6:com.ibm.xsp.component.xp.XspSelectManyCheckbox = getComponent("check6");
ArrSelected = check6.getSelectedValues();
to get the selected values, the following exception occurs:
Error calling method 'getSelectedValues()' on java class 'com.ibm.xsp.component.xp.XspSelectManyCheckbox'
java.util.ArrayList incompatible with [Ljava.lang.Object;
Check6 gets its values from a session scope variable that is computed on beforePageLoad event and I have also set the default value.
Note that this does not happen onload of the page, but when the first partial refresh happens. Does anyone know what this exception indicates?
Thanks a lot!
Bind the value of the selectItems for the second check box group to precisely the same expression the first checkbox group's value attribute is bound to.
This article provides a lengthy description of the reason why, but here's a very quick summary: if you ask a component what its value is, it has to ask the data it's bound to. So skip the component, and ask the data yourself.
So, if your first group looks like this:
<xp:checkBoxGroup value="#{currentDocument.FirstField}">...
Then your second group should look like this:
<xp:checkBoxGroup value="#{currentDocument.SecondField}">
<xp:selectItems value="#{currentDocument.FirstField}">
</xp:checkBoxGroup>
When the user's selection in the first group is posted to the data source, the second group will reflect the changes because they're linked to the same property on that data source. Slight caveat: if your page includes any required fields, you may need to skip validation on the onchange event that triggers the second group to recalculate.
the reason is simple, this class has no method getSelectedValues() (as far as I can see it, look here for more info: http://public.dhe.ibm.com/software/dw/lotus/Domino-Designer/JavaDocs/XPagesExtAPI/8.5.2/index.html?overview-summary.html)
Maybe you could bind the control to a scoped variable and then access this variable to compute your other values?

Programmatically hiding an SPField

I'm having trouble hiding a SPField from the user view programmatically.
I tried the obvious way of:
SPField newField = web.Site.RotWeb.Fields.GetField("order");
string newField = list.Fields.Add(newField);
list.Fields["order"].Hidden = true; // <--- exception: read-only field
list.Update();
The exception says the field is read only so I can't modify it.
This field is added in the code and hence it'll be unghosted from the field collection. Besides from the UI, how can I make the field hidden?
Thanks.
First, try setting ReadOnlyField to false (then back to true after setting Hidden).
If that does not work, check the value of CanToggleHidden. If CanToggleHidden is false, you can either:
Override it with reflection as in this example.
Add the field using XML as in this example. Note: if you need to use an existing site column, you can try adding ID attribute with the column's Guid to the XML string.
Skip Hidden and use ShowInDisplayForm, ShowInEditForm, and ShowInNewForm instead.
nevermind, I saw that you are adding the field. try getting a new instance of the field after it is created and then applying the hidden atttribute before updating the list.

Person & Group custom field type sharepoint

I have created a custom field type as it is there in sharepoint OOTB, the difference is only that the end user does not need to check the name i.e I have replaced it with DropDownList. The dropdownlist suggest the no. of users available in the web site for that I have created a FieldClass which inherits from SPFieldUser and a FieldControlClass which inherits from UserField. It is working fine in all conditions i.e when I create a List or Document Libarary it shows me the DropDownList
with respective users after saying OK it creates an item for me. I have overriden a Value property in FieldControlClass as follows,
public override object Value
{
get
{
SPUserCollection userscollection = rootWeb.SiteUsers;
//ddlInfoBox is a DropDownList to which I have Binded the collection of users in the form of string
SPUser user = userscollection.Web.EnsureUser(this.ddlInfoBox.SelectedValue);
SPFieldUserValue userval = new SPFieldUserValue(user.ParentWeb, user.ID, user.LoginName);
return userval;
}
set
{
SPFieldUserValue userval = (SPFieldUserValue) this.ItemFieldValue;
this.ddlInfoBox.SelectedValue = userval.Lookupvalue; //Here look up value is nothing but a Login name e.g In-Wai-Svr2\tjagtap
}
}
Due to above property the Custom Field's Value for this current ListItem will be stored as SPFieldUserValue e.g 27#;In-Wai-Svr2\tjagtap.
The main problem is here, when this particular ListItem is shown in the list page views e.g on AllItems.aspx or the custom view pages associated with it, it shows the
number as 27 as a FieldValue insted of HyperLink with text as "In-Wai-Svr2\tjagtap" and PostBackURL as "/_layouts/userdisp.aspx?ID=27".
When I edit this Item it makes the respective value selected in the dropdownlist, also while viewing this item i.e on DispForm.aspx it also shows the hyperlink. I have
acheived it by writting a custom logic in createchildcontrol() method i.e by using ControlMode if it is New or Edit then fill the dropdown list, if it is Display then get the ItemFieldValue Type Cast it into SPFieldUserValue and get corresponding lookupid and value for making the URL and showing Text of the HyperLink.
I have spent a lot of time on searching and bringing the HyperLink as the user name with navigation insted of UserID (27) as a string on the list view pages e.g AllItem.aspx but to no avail, then after a lot of research I found that there might be a way of achieving such kind of functionality by using field type definition xml file where there is a provision to define a DisplayPatteren as you wish by specifying the html code. But here is a problem How can I get the UserID (27) with respective UserName e.g In-Wai-Svr2\tjagtap inorder to make an anchor tag like In-Wai-Svr2\tjagtap which will solve my problem. I have hard coded this anchor tag within the Default case statement of a switch under DisplayPatteren but it shows me the field value on AllItems.aspx as
In-Wai-Svr2\tjagtap27 i.e the value defined in xml file is concatenating with the string value (27).
Please help me to resolve the above mentioned 2 issue. I am really in need of solving this problem ASAP.
Thanks & Regards,
Tejas Jagtap
Have u tried to override the GetFieldValueAsHtml() method in the the custom field class or maybe the RenderFieldForDisplay() method in the custom field control class.
Can you use the DisplayPattern CAML from the User field type?

Resources