How to select custom layout to use in Apache POI - apache-poi

I have a pptx with following slide layouts:
System.out.println("Available slide layouts:");
for(XSLFSlideMaster master : ppt.getSlideMasters()){
for(XSLFSlideLayout layout : master.getSlideLayouts()){
System.out.println("Name: "+layout.getName()+" Type: "+layout.getType());
Available slide layouts:
Name: Content Type: OBJ_ONLY
Name: Title and 4 Content Type: FOUR_OBJ
Name: Title Only Type: TITLE_ONLY
Name: DETAIL_SCORECARD Type: CUST
Name: Scorecard Type: CUST
Name: CSCLayout1 Type: CUST
Name: 1_Blank Type: BLANK
Name: Title, Content, and 2 Content Type: OBJ_AND_TWO_OBJ
Name: Title and Content Type: TITLE_AND_CONTENT
Name: Title, Text, and Content Type: TX_AND_OBJ
Name: Two Content Type: TWO_OBJ
Name: Main Type: TITLE
How do I go about selecting 2nd or 3rd CUST layout option
Current implementation works fine with 1st CUST slide layout
FileInputStream input = null;
input = new FileInputStream(filename);
slideshow = new XMLSlideShow(input);
XSLFSlideMaster defaultMaster = slideshow.getSlideMasters()[0];
XSLFSlideLayout detailedscorecard = defaultMaster.getLayout(SlideLayout.CUST);
I've tried renaming the slide name within slide master, but it doesn't seem to have any affect on the above list. is there a way to use layout.getName() to find the actual name of the slide layout,
XSLFSlideLayout detailedscorecard = defaultMaster.getLayout(SlideLayout.CUST);

ok.. got an answer from a friend and got it resolved...
XSLFSlideLayout detailedscorecard = null;
for (XSLFSlideMaster master : slideshow.getSlideMasters()){
for (XSLFSlideLayout layout1 : master.getSlideLayouts()){
if (layout1.getName().equals("Scorecard")) {
detailedscorecard=layout1;
}
}
}

Related

I want to make a custom form in NetSuite with a list of Status after enabling Inventory Status with no empty field option

`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')
});
});

SuiteScript 2.0 Suitelet Sublist with line-specific "Select" options

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.

Adding Radio Button on Suitelet SS2.0

I am adding the radio button on Suitlet page but it is throwing an error while loading the page. I am not sure where I am going wrong.
var custType1 = form.addField({
id: 'custpage_customertype',
name: 'retail_customer',
type: serverWidget.FieldType.RADIO,
label: 'Retail Customer',
container: 'companygroup'
});
var custType2 = form.addField({
id: 'custpage_customertype',
name: 'corporate_customer',
type: serverWidget.FieldType.RADIO,
label: 'Corporate Customer',
container: 'companygroup'
});
var custType3 = form.addField({
id: 'custpage_customertype',
name: 'external_customer',
type: serverWidget.FieldType.RADIO,
label: 'External Customer',
container: 'companygroup'
});
While running the code, I am getting error on this line saying SSS_MISSING_REQD_ARGUMENT. Following is the error code -
{"type":"error.SuiteScriptError","name":"SSS_MISSING_REQD_ARGUMENT","message":"nlobjField: Missing a required argument: radiobuttons: sSource","stack":["addField(N/serverWidget)","(/SuiteScripts/sdr_sw_suitelet_test.js:123)"],"cause":{"type":"internal error","code":"SSS_MISSING_REQD_ARGUMENT","details":"nlobjField: Missing a required argument: radiobuttons: sSource","userEvent":null,"stackTrace":["addField(N/serverWidget)","(/SuiteScripts/sdr_sw_suitelet_test.js:123)"],"notifyOff":false},"id":"","notifyOff":false,"userFacing":false}
You need a source property which will be like the id of the radio button. This will be the value used by the script to know which radio button was selected. Something like
var custType1 = form.addField({
id: 'custpage_customertype',
name: 'retail_customer',
type: serverWidget.FieldType.RADIO,
label: 'Retail Customer',
source:'retail',
container: 'companygroup'
});

Text search in Mongo

I have some mongoose schema:
const Article = new Schema({
name: { type: String, required: true },
message: { type: String, default: "" },
searchField: { type: String, default: "" },
...
});
searchField is a combination of name and message fields.
And index:
Article.index({searchField: 'text'});
Then when I need search in list of Articles:
query.$text = { $search: data.search }.
And it works, but with some problems.
The first one - it can't find Article when data.search.length <= 3. For example, name = 'bag' and data.search = 'bag', it doesn't work (ok if language is english).
And the second one - if name = 'subtitles' and data.search = 'sub', there is no result.
What is wrong?
MongoDB shell version: 3.0.6
You can search with a regex. Change your query to this:
Article.find({searchField: /sub/i});
The double / allows you to search only for a part of a word. The i at the end ignores lower- and uppercase.
(Please note that this only searches in the specific field searchField)

Populating a dropdown list in form with another models data in nodejs

I am trying to populate a dropdown list for a form for one of my models (cars), with data from another model (colours), but cannot seem to figure out how to do this. I need to somehow call the list of colours into the dropdown in the cars.jade file, so that when a user selects the auto-filled list I need the ObjectID to be the value of the item (which subsequently is saved as a new car.
Cars New Form (car.jade):
/* This is the bit I'm having trouble with */
select(name='carColours')
option(value='')
each colour in colours
- var select=null; if (colour.title == carColours.title) select='selected';
option(value=colour._id, selected=select)= colour.title
Cars controller (cars.js):
exports.new = function(req, res){
res.render('cars/new', {
title: 'New Car',
event: new Car({})
})
}
Cars model (car.js):
var CarSchema = new Schema({
title: {type : String, default : '', trim : true},
colour: {type : Schema.ObjectId, ref : 'Colour'},
})
Colours model (colour.js)
var ColourSchema = new Schema({
title: {type : String, default : '', trim : true},
hexadecimal: {type : String, default : '', trim : true},
})
ColourSchema.statics = {
list: function (options, cb) {
var criteria = options.criteria || {}
this.find(criteria)
.sort({'title': 1}) // sort alphabetically
.exec(cb)
}
}
Your call to render in cars.js needs to supply the list of colors.
exports.new = function(req, res){
res.render('cars/new', {
title: 'New Car',
event: new Car({}),
colours: [<list of possible colours>]
})
}
The object you pass to render after the path to the view template is the context in which your view template operates. If that object doesn't have the property in question (in this case colours), then neither will your view template. (There is an exception to that, but it doesn't look like you're using it here).
I go into this in the latest episode of a screencast series I produce (http://www.learnallthenodes.com/episodes/9-view-templates-in-nodejs-with-jade). I'm not sure the exact timestamp of when I hit that part.

Resources