If I set up my own segmented key ID to be used with a custom DAC's identity field, Do I need anything else other than the [PXDimension] attribute on that DAC field to implement the enforcement of that segment setup?
You would have to define your custom field with the [PXDimensionSelector] attribute.
When this attribute is used, the first parameter should be the dimension name (defined in the Segmented Keys page - CS202000), followed by the ID value (this is the value persisted in the DB), and then the CD value (this is the user-friendly value).
For instance, the Item Class Dimension selector can be defined like this:
[PXDimensionSelector(INItemClass.Dimension,
typeof(Search<INItemClass.itemClassID, Where<INItemClass.stkItem, Equal<False>>>), typeof(INItemClass.itemClassCD), DescriptionField = typeof(INItemClass.descr))]
When the value is then added to the UI, the framework will recognize the Dimension-selector attribute and it will create it as a PXSegmentMask field instead of a regular PXSelector
Related
See Problem Image
If UserCreationAttribute is created by Omiting one field in UserAttribute Why we using
both in that Arrow and what does it mean I'm confused.
The first generic parameter UserAttribute is used to control what fields can be in the model and the second one UserCreationAttribute is used to validate a set of fields while creating an instance of this model. Usually a primary key field is omitted from creation attributes because it's auto generated. You should add all optional fields there along with the PK field that are not needed if you create a model instance.
It's your responsibility to define creation attributes as a subset of all attributes that's why it's recommended to use Optional with attributes.
I have retrieved an entity from my table. I want to set one of the property to null. Can I do that?
Simple answer is No. You can't set a property's value to null.
Essentially Azure Table is a key/value pair storage. An entity contains attributes and each attribute must have a name, type and value and the value can't be null.
One thing you could do is remove that particular attribute from the entity. The approach for that would be:
Fetch the entity.
Remove the attribute from the entity for which you want to set the value to null.
Update the entity.
Quick question.
I have a custom two-option field on an entity, with "Yes"/"No" as the values; "Yes" has the underlying value 1, while "No" has the underlying value 0. I've set the default value for this field to "Yes". However, when I create new entity records, the field always gets the value "No" (0 in the database). It seems to be ignoring the default value I've set. Why?
The field is not present on any of the entity forms, as it's only used in underlying plugin code. Should that matter?
Are you creating a new record for this entity using code that uses the strongly-typed objects? If so, when you create a "new" entity in code, I'm guessing the class itself is setting that field to "false" by default. I don't think those generated classes respect the default values in the metadata. I also think that all fields are submitted on a create when you use these generated classes. That means that your class is setting it to "no" by default and then on create, the system thinks that you explicitly set it to "no" so default values are not applied. I think you need to explicitly remove that attribute from the attribute collection of your entity before you create it. That way the system should respect the default value on create. Sorry for all the "I thinks" but I'm not in a place that I can test or verify all of this. :)
In my JSF page, I have a <rich:autocomplete/> which must be filled by selecting an object from the list. The id of the object does not have useful meaning, so I have to write a Converter to change it to readable string.
Unfortunately the string representation of the object could not uniquely identify different objects and so the conversion is not reversible. Now I want to know how I could solve this problem? Is it possible to store the id of the selected object into a <h:inputHidden> and pass it to the view scoped backing bean?
You're using the input component and the converter the wrong way. You are apparently using the object's string representation (the item label) as input value, while you should be using the object's unique identifier (the item value) as input value. The converter is merely to convert between the custom object and the unique identifier, not between the custom object and the string representation.
I have searched this and until the moment there are no direct solution provided by the rich:component as it does not has itemValue like rich:select
Also there are 2 workaround solution.
to use JavaScript to add the id value of the selected item to a
hidden field and then use this hidden field to identify the
selected item
I used the fetchValue attribute to concat item_id - item_name
then I created a converter which substring the item_id to identify
the selected item.
In SharePoint many fields id-value pairs that are formatting like the following id;#value. This is further complicated with fields like multi-lookup where when extracting the value of that field can yield results like id_1;#value_1;#id_2;#value_2;#id_3;#value_3
I am wondering if there is any known built in function that will simplify this process and at the very least remove the IDs from the value.
Field value objects are stored as strings in the Sharepoint database. For simple values (e.g. "Hello world") this is simple enough. But for complex field values - such as an ID/value pair, how to store the entire value as a single string is obviously more complex as well. Each field value class in Sharepoint is responsible for its own storage implementation. ToString() is responsible for writing a string representation of the value; while the field value's constructor takes a string and is responsible for parsing that and setting all the properties on itself appropriately.
For example, the SPFieldUrlValue (which represents an description) has Url and Description properties. Creating a new SPFieldUrlValue(string fieldValue) object will parse the value and set the properties accordingly.
In order to get a true/correct (and often strongly-typed!) representation of the field value, you must know what type the field is, and what that field's value class is.
The SPField class has many derived classed
For example assuming a Lookup field type (that uses the ID;#value) you can check SPField.Type == SPFieldType.Lookup and then cast SPField to SPFieldLookup and use its overriden methods to get the records value.
See Custom Field Value Classes for more details
Also - If I remember correctly (I can't check this right now so DYOR) you can call .ValueAsText and .ValueAsHtml on the base SPField object and it will remove ID;# from the values.