Ho do I implement the property converter for value providers in RAD data Form - nativescript-angular

I have a RAD data form in my nativescript-angular app. The form has two fields for ID type and ID number. The ID type field is a picker that displays data from a backend service. My source Object looks like:
this.mySourceObj = new User("Passport Id", "A2653JHSJ12");
I want my source object to store the value of the ID type as a string.
So I changed the editors using HTML markup, like:
<TKEntityProperty
tkDataFormProperty
name="idType"
displayName="Id Type"
index="1"
[valuesProvider]="idTypesProvider"
>
<TKPropertyEditor
tkEntityPropertyEditor
type="Picker"
></TKPropertyEditor>
</TKEntityProperty>
and in my ts file I register my valueproviders like:
this.idTypesProvider = {
key: "id",
label: "name",
items: [...idTypesArr]
};
With this set, my picker editor gets populated with the data but when I select one item, it does not reflect in my code so at the time of form submission the field is null.
I would like to get the value of the selected item as a complete object i.e. (id, name, ...).
I have tried using the property committed event to get the committed value but it is logs an index value of the item.
if (args.propertyName === "idType") {
const selectedIdType = this.mySourceObj.idType;
console.log(`the committed id type is :`, selectedIdType);
} else {
console.log("No property selected");
}
I have also come across the property convert that is attatched in the dom like:
<TKEntityProperty
tkDataFormProperty
name="idType"
displayName="Id Type"
index="1"
[converter]="valsConverter"
[valuesProvider]="idTypesProvider"
>
<TKPropertyEditor
tkEntityPropertyEditor
type="Picker"
></TKPropertyEditor>
</TKEntityProperty>
But I do not know how to implement the "Converter". Any help is highly appreciated.
I want a situation where when the user selects an ID type, my console can log The complete object of the selected Item.

Related

How to extend the core customer table?

I created a custom table with additional settings for customers. Next I added a field to the customer core table in which I'd like to store the id choice per customer. I extended with EntityExtensionInterface the customerDefinition :
public function extendFields(FieldCollection $collection): void
{
$collection->add(
(new OneToOneAssociationField(
'customerSetting',
'customer_setting',
'id',
WdtCustomerSettingsDefinition::class,
true
))->addFlags(new Inherited())
);
}
public function getDefinitionClass(): string
{
return CustomerDefinition::class;
}
When I manually manipulate the customer table, with an id from my custom table in the added field, I can retrieve and use the settings from my custom table in the storefront.
For the backend I created a single select to the entity custom_table,
<sw-entity-single-select entity="wdt_customer_settings" v-model="customer.extensions.customerSetting.id" >
</sw-entity-single-select>
and with the manually 'injected' id from the custom table, this choice indicates indeed 'selected' However, after changing to another choice and saving results in an error: Customer could not be saved.
What am I missing?
You should look always to the ajax responses. There is the explict error which is occured. Do you added some boilerplate code to check that your extensions is always available? Otherwise it would cause issues on new entities

ng-admin: Showing reference fields in a referenced_list

Using ng-admin, I have a referenced_list defined as follows against my companies entity to display all the events registered for a company:
nga.field('companyevents', 'referenced_list') // display list of related profiles
.label('Company Events')
.targetEntity(companyEvents)
.targetReferenceField('companyid')
.targetFields([
nga.field('eventid')
])
.perPage(10)
.listActions(['edit']),
The target field 'eventid' is itself a reference to an event with an event name. Is there any way I can lookup the event name, rather than just showing the eventid which is pretty meaningless on its own? (E.g. some kind of lookup from a map() call?) When I'm displaying a list view, I can access the event name easily using a reference field:
nga.field('eventid', 'reference')
.label('Event')
.targetEntity(events)
.targetField(nga.field('eventname')),
Is this working?
nga.field('companyevents', 'referenced_list') // display list of related profiles
.label('Company Events')
.targetEntity(companyEvents)
.targetReferenceField('companyid')
.targetField(
nga.field('eventid').map(function (value, entry) {
return entry.eventname})
)
.perPage(10)
.listActions(['edit']),

How to create a Custom Select List for a netsuite field?

I have a field on a custom record. The name of the field is reference_code.
I want to populate "reference_code" with my own dynamic list which would be presented as a drop down to the user.
How do I do this? I defined my field as Free-Text. Do I need to keep it hidden but then show it as a drop down before I load the form?
I thought this might do something:
nlapiInsertSelectOption('custrecord_rulereferencecode', code, code, false)
But I would need to convert the field to a select?
Typically, instead of creating the field as Free-Text, you would first create a Custom List (Customization > Lists/Records/Fields > Lists > New) with all of your dropdown options.
Then you would create your field as a List/Record field and select your new Custom List as the "List/Record Type", as depicted below.
This can be done by giving a source to your drop-down menu. The source field accepts an internal id of a list. This internal id can be an in-built(provided by netSuite) or a custom list created by a user. For Eg: I have a custom list with an internal id '23' which has some list items in it, these can be populated in the drop down menu by the following syntax.
var start = function(request, response)
{
var form = nlapiCreateForm('Custom Form');
form.addField('custpage_selectfield', 'select', 'select a color', '23');//here 23 is the internal id of my list
respnose.writePage(form);
}
or you could generate you own field's dynamically using the addSelectOption() function.
var start = function(request, response)
{
var form = nlapiCreateForm('Custom Form');
var myselectfield = form.addField('custpage_selectfield', 'select', 'select a color');
myselectfield.addSelectOption('1', 'Red');//Here 1, 2 and 3 are the id's
myselectfield.addSelectOption('2', 'Green');//which are returned when the
myselectfield.addSelectOption('3', 'Blue');//form is submitted
respnose.writePage(form);
}
I solved this by creating two fields. One is created in the RecordType and will store the info. I set this as hidden. The next field, with the custom dropdown is added in user event. I then process data for my custom dynamic select list and add that to my added user event field.
Then in my change event, I set the record type field to the value selected in my dynamically added field.
Userevent
function userEventBeforeLoad(type, form, request){
if(type == "edit"){
form.addField('custpage_referencecode','select','Reference Code',null, null)
}
}
In my Client Script:
function clientFieldChanged(type, name, linenum){
if(name == 'custpage_referencecode'){
//obtain the upper case value
var codetext = nlapiGetFieldValue(name)
//make sure it hasn't been set
if (codetext != nlapiGetFieldValue('custrecord_rulereferencecode'))
{
nlapiSetFieldValue('custrecord_rulereferencecode', codetext );
}
}
return true
}

Get view name in xpages view control

I'm using a view control to display a notes view. We are also using a search function, to search the first column of each view. As we want to save the search parameter a user has entered, we've created a bean saving the search key for each user.
To save the seach key, we are using this code in the data > keys property of a view control:
var dbName:String = database.getFilePath();
var viewName:String = "vwCurrentRequests";
var searchValue:String = searchUserBean.getSearchValue(dbName+viewName);
if(searchValue.isEmpty() || searchValue==null) {
return "";
} else {
return searchValue;
}
But we always have to define the viewName value for each view. So the question is: How can we get the view name of the current view?
You can access the name of the view with this SSJS code:
getComponent("viewPanel1").getData().getViewName()
viewPanel1 is the id of your view panel.
EDIT:
As Frantisek Kossuth wrote, you can use the this keyword instead of the getComponent.
this.getData().getViewName()

how to add "sendemail" button in gridView of customized entity in crm

There is one customized entity named as "Add to Campaign" . Since there is no default "Email" button in sub-grid , so i placed one customized button and provided javascript to open Email form , and the Email form opens good.
But now the problem is , cant able to get selected records "Email field" in "Send to field" in Email Form.
so how to get selected record email to be displaced in "Email Form"
Open the email form with parameters:
Xrm.Utility.openEntityForm("email", null, param);
var param = {}; // passed as parameters to the new email form
if(Xrm.Page.getAttribute("-- LogicalNameOfField --") // make sure that the field has a value
param["-- LogicalNameOfFieldInNewEmail --"] = Xrm.Page.getAttribute("-- LogicalNameOfField --"); // passes a field value to the new form
// This passes a lookup field as a parameter to the new form
if(Xrm.Page.getAttribute("-- LogicalNameOfLookup --").getValue() != null) { // make sure that the lookup field is not empty or we will have a problem trying to access [0].id and [0].name
param["-- LogicalNameofLooupFieldInEmail --"] = Xrm.Page.getAttribute("-- LogicalNameOfLookup --").getValue()[0].id;
param["-- LogicalNameOfLookup --" + "name" (eg. "accountname")] = Xrm.Page.getAttribute("-- LogicalNameOfLookup --"].getValue()[0].name;
Xrm.Utility.OpenEntityForm("LogicalEntityName", null, param); // open the form and pass parameters
Take note of how the lookup field is passed as a parameters:
2 parameters are passed for each lookup field
The GUID as the name of the lookup field (account if account if the name of the lookup field in the new email)
The name of the lookup in the source entity as a special parameter (accountname)
Note: there is no field called "accountname", but there is a field called "account" in this hypothetical entity

Resources