How to set default value of ProductType attribute in Commercetools platform? - platform

I wanna to set up default value if a ProductType attribute is empty or null.
This is the documentation I referred: https://commercetools.github.io/commercetools-jvm-sdk/apidocs/io/sphere/sdk/meta/ProductAttributeDocumentation.html

There is currently no default value that can be defined in product type attributes.
You could create a custom object for that purpose.
How do you plan to manage your product data?
Will you sync from an external system?

Related

Association without ReferenceVersionField

Is it possible to have a OneToManyAssociationField as entity extension on for example ProductManufacturer without the ReferenceVersionField in my related custom entity?
If this is not possible, is it possible for the reference version field to have a custom name (so not product_manufacturer_version_id) On first sight, this also does not seem possible.
About the error
I am currently getting the following error when trying to search for manufacturers using $criteria->addAssociation('myCustomEntity'):
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'product_manufacturer.myCustomEntity.product_manufacturer_version_id' in 'field list'
About the big picture
The use case is similar to the SeoUrl entity where there is a ‘foreign_key’ field which can have a relation to multiple entity types. My entity has not associations, but the other entities are extended to have an association to my entity. Just like the SeoUrl.
However, the DAL creates a query which uses the ‘product_manufacturer_version_id’ field, which does not exist on my custom entity…
Is it possible to have a OneToManyAssociationField as entity extension on for example ProductManufacturer without the ReferenceVersionField in my related custom entity?
No, you must set a ReferenceVersionField when adding associations to the definition of a versionized entity. This is too deeply rooted in the basic principles of the data abstraction layer to work around.
If this is not possible, is it possible for the reference version field to have a custom name (so not product_manufacturer_version_id) On first sight, this also does not seem possible.
You can change the storage name of the field. That is the name of the corresponding column within your database table. When you instantiate ReferenceVersionField you can use the second, optional argument to provide the storage name:
public function __construct(string $definition, ?string $storageName = null)
The storage name should be provided in snake case. The name of the object property for the field will then be derived from the storage name and converted to camel case. So given you provide my_version_custom_id for the storage name, the object property of the entity will be myVersionCustomId.
Your entity may have multiple associations to different entities, but if those entities are versionized your foreign key constraint has to be a combination of columns for both the foreign primary key as well as the foreign version id.

Question about the [PXDimension] attribute

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

Can l use PowerShell to update the property of entity in azure storage to null

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.

Dynamics CRM is ignoring the default value for two-option field

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. :)

Net Suite Override internal id

Is this possible to set or override the internalid of a custom record type ?
The internalid is self generated, but I want to try to set inernalid value from a cvs field.
I do not believe you can override the internalid of any record instance, even a custom one. You can, however, use the externalid field that I believe every record has if you want to specify a "secondary" identifier for the record.
You cannot override the internal ID of a record. As mentioned in a previous response to your question, you can (and should) set the external ID field on the NetSuite records to equal the primary key of the data being imported.
On future imports that update NetSuite data, you simply map the key field of the imported data to the external ID field in NetSuite. You can ignore the internal ID field on those future imports, as Netsuite will match up the records based upon the external ID.
This is the proper way to do this - I've seen tons of situations where people did not understand the external ID concept, and created huge, long term maintenance issues by not following this simple solution.
OK. Given your feedback, why not create another custom field on the customer record that references the lookup value in the custom record?
The field type should be the same as the field type of the lookup value, with "store value" checkbox unchecked. On the Sourcing and Filtering tab, you specify the custom record type and field to reference. Think of it as a SQL join of sorts between the customer record and custom record.
Then, you should be able to do what you want with 2 getCurrentAttribute tags:
<%= getcurrentattribute('cusomter', 'custentity_mappingid')%>
<%= getcurrentattribute('cusomter', 'custentity_mappingvalue')%>
BTW, your custom field internal IDs look a little odd. They should start with 'custentity', and 'custrecord', respectively. My code above reflects what you'd normally expect from NetSuite.
You can set ExternalId and if you want to get record then you can use callGetRecordByExternalId .
public ReadResponse callGetRecordByExternalId(String externalId, RecordType recordType) throws RemoteException {
return this.callGetRecord(Utils.createRecordRefWithExternalId(externalId, recordType));
}

Resources