When adding an address element to my stripe form, Only the 'Address Line 1' appears by default. Once the user starts typing in their address the rest of the fields are displayed. Is it possible to show all of the address element fields when the form is ready and not hide 'Address line 2', 'City', 'State', 'Zip', and 'Phone number' by default?
Looks like the only way to currently expand the address element fields is to set default values when creating the address element. It looks like passing default values for just state and country will render the remaining fields. The phone field will also be expanded as long as the 'always' value is specified in fields.phone.
You'd do something like this:
const addressElement = elements.create("address", {
mode: "shipping",
defaultValues: {
address: {
state: 'CA',
country: 'US',
},
},
fields: {
phone: 'always',
},
});
Related
`sublist.addField({
id: 'INV_STATUS',
label: 'INV_STATUS',
type: serverWidget.FieldType.SELECT,
source: 'inventorystatus'
});`
I am using this code to add a field to sublist but the sublist has first value as empty.
You have to populate the list manually to avoid an empty option.
var list = sublist.addField({
id: 'INV_STATUS',
label: 'INV_STATUS',
type: serverWidget.FieldType.SELECT
});
search.create({
type: search.Type.INVENTORY_STATUS,
columns: 'name'
}).run().each(function(result) {
list.addSelectOption({
value: result.id,
text: result.getValue('name')
});
});
I currently have a nice suitelet popup as a PDF Report selection. Everything so far works nicely.
However, some of the available PDF reports require individual options to be passed. ie. a date, or a class selction specific to ONLY 1 of the forms.
Currently I have created the sublist:
var documentList = form.addSublist({
id: 'documentlist',
label: 'Documents Available'+ (data.job ? ' for Job Number: '+data.job : ''),
type: serverWidget.SublistType.LIST
})
documentList.addField({ id: 'mark', type: 'CHECKBOX', label: 'Print'});
documentList.addField({ id: 'config', type: 'SELECT', label: 'Form', source: 'customrecord_advancedformconfig' }).updateDisplayType({displayType : 'INLINE'});
documentList.addField({ id: 'vardate', type: 'CHECKBOX', label: 'Variation Dates' }).updateDisplayType({displayType : 'INLINE'});
documentList.addField({ id: 'document', type: 'TEXT', label: 'Document', }).updateDisplayType({displayType : 'HIDDEN'});
documentList.addField({ id: 'primaryrecord', type: 'TEXT', label: 'Main Record'}).updateDisplayType({displayType : 'INLINE'});
documentList.addField({ id: 'storeincabinet', type: 'CHECKBOX', label: 'Save to Cabinet'}).updateDisplayType({displayType : 'INLINE'});
documentList.addField({ id: 'filename', type: 'TEXT', label: 'File Name to be Generated'}).updateDisplayType({displayType : 'NORMAL'});
var pdfOptions = documentList.addField({ id: 'formoption', type: 'SELECT', label: 'Option' }).updateDisplayType({displayType : 'NORMAL'});
The last line is the sublist field for the form options.
Lets assume the first line requires a couple of date options, while the second line requires a couple of size or colour options.
As there is only a "field" action to pdfOptions.addSelectOption(...) this adds options to ALL occurences of the field.
Is there a method for each LINE of the sublist, to set options for just a single line??
There is no pdfOptions.addSublistSelectOption(...) so I'm going to guess the answer is not, but thought I would ask anyway.
To illustrate, see below image... Only the last line should have a date dropdown.
The way I've accomplished having different select options for different lines is using a client script with the lineInit entry point that cleared out the existing options and added relevant ones for that line.
However you would need to change the sublist type from LIST to EDITOR or INLINEEDITOR for this to work, which probably wouldn't work well in your use case.
Is there any way to insert the same line in multiple rows of a YAML file. For example the YAML:
fields:
id:
label: ID
disabled: true
full_name:
label: Full Name
shipping_address:
label: Shipping Address
should become:
fields:
id:
label: ID
disabled: true
span: auto
full_name:
label: Full Name
span: auto
shipping_address:
label: Shipping Address
span: auto
Give this a try:
:g/\v^(\s{4})\S+:/exe "norm! YpAfoo: bar\<esc>^df:>>>>"
You should change the {4} to the right indentation, it depends on the new item goes under which level.
This will insert the new entry in the first position.
With your example:
Something almost perfect:
g/label:/ put=' span: auto'
The only problem happens on the ID block, or how to get the final line as a pattern to use in the global command.
I have to add multiple buttons on Card or Basic card. Is it possible ?
In dialog flow documentation, its mentioned there is one element buttons which takes array of element. Based on this I have added buttons like:
agent.add(new BasicCard({
title: body.hits.hits[i]._source.name,
formattedText: '',
image: {
url: body.hits.hits[i]._source.images ? body.hits.hits[i]._source.images[0].src : '',
accessibilityText: 'Logo',
},
buttons: [{
title: "Buy",
openUrlAction: {
url: body.hits.hits[i]._source.buy,
}
},{
title: "Add to Cart",
openUrlAction: {
url: body.hits.hits[i]._source.aad_to_card,
}
}
],
}));
But its throws error as below:
throw new Error(`Unknown response type: "${JSON.stringify(response)}"`);
Some places its mentioned buttons takes only one element. So what's the point of making it array ?
A BasicCard can only have one button. That is the current rule. I can't give a good reason on why it is in an array even if it only accepts one element.
I know how to set the optionList on Initiliaztion but how do I set it programmatically?
I have an inviteList array:
$("#select-invite").options(inviteList);
You can use load method to set options via programmatic API. You may also want to call clear and clearOptions methods to reset selected values and old options.
Here is how to put it all together:
var selectize = $("#select-invite")[0].selectize;
selectize.clear();
selectize.clearOptions();
selectize.load(function(callback) {
callback(inviteList);
});
Please note that inviteList should be an array of objects that have properties configured in valueField and labelField options when select was initialized. For example, here is how inviteList should look like with default valueField and labelField options:
var inviteList = [
{
text: 'Option One',
value: 1
},
{
text: 'Option Two',
value: 2
}
];
As far as I know there's no method for adding multiple options through the API. You'll need to write a loop that uses the addOption() method. You'll need to get the control instance of selectize before trying to use the API. Take a look at the example below, from the Github examples:
// Create the selectize instance as usual
var $select = $('#select-tools').selectize({
maxItems: null,
valueField: 'id',
labelField: 'title',
searchField: 'title',
options: [
{id: 1, title: 'Spectrometer', url: 'http://en.wikipedia.org/wiki/Spectrometers'},
{id: 2, title: 'Star Chart', url: 'http://en.wikipedia.org/wiki/Star_chart'},
{id: 3, title: 'Electrical Tape', url: 'http://en.wikipedia.org/wiki/Electrical_tape'}
],
create: false
});
// Get the selectize control instance
var control = $select[0].selectize;
// Add the new option when a button is clicked
// Remove the click event and put the addOption call in a loop
$('#button-addoption').on('click', function() {
control.addOption({
id: 4,
title: 'Something New',
url: 'http://google.com'
});
});
From the Github examples.
I know this is an old question but as of 2021 I have found this to be the simplest way to achieve this:
Building on #byte255's answer above, you only need to use the clearOptions method and addOption method.
let selectize = $("#select-invite")[0].selectize;
selectize.clearOptions();
let newOptions = [
{
text: 'Option One',
value: 1
},
{
text: 'Option Two',
value: 2
}
]
selectize.addOption(newOptions);