I have tried a code about auto generating id. I want to try it on JTextField, but I don't know where i should put it.
Here is my code:
--PembelianController.groovy--
String generateID() {
String date = DateTime.now().toString("yyyyMMdd")
List list = findAllPembelian([orderBy: 'noNota', orderDirection: 'desc'])
Integer num = list.size()==0? 0: list[0].kode[12..-1].toInteger() + 1
return String.format("NT00%s%04d", date, num)
}
--PembelianView.groovy--
label('No Nota:')
textField(id: 'noNota', columns: 20, text: bind('noNota', target: model, mutual: true), errorPath: 'noNota')
errorLabel(path: 'noNota', constraints: 'wrap')
Well, it depends on when you want to do it. You can assign textField.text = generateID() at any time. You may assign the value during the binding
textField(id: 'noNota', columns: 20, errorPath: 'noNota',
text: bind('noNota', target: model, mutual: true, value: generateID()))
Related
#bknights posted an good answer to another question around populating a sublist in a suitelet.
However, my question follows on from that when using bk's code:
function getJoinedName(col) {
var join = col.getJoin();
return join ? col.getName() + '__' + join : col.getName();
}
searchResults[0].getAllColumns().forEach(function(col) {
sublist.addField(getJoinedName(col), 'text', col.getLabel());
nlapiLogExecution('DEBUG', 'Column Label', col.getLabel());
});
var resolvedJoins = searchResults.map(function(sr) {
var ret = {
id: sr.getId()
};
sr.getAllColumns().forEach(function(col) {
ret[getJoinedName(col)] = sr.getText(col) || sr.getValue(col);
});
return ret;
});
sublist.setLineItemValues(resolvedJoins);
The above works with a standard search with no formulae... How can we do this when I have multiple search columns which are formulae?
Using API1.0
In your search definition add a label to all formula columns. Then your column keys can be derived like:
function getJoinedName(col) {
if(col.getName().indexOf('formula') === 0 && col.getLabel()){
return 'lbl_'+ col.getLabel().toLowerCase();
}
var join = col.getJoin();
return join ? col.getName() + '__' + join : col.getName();
}
You can just get all the columns of the search result. columns = result[0].getColumns(). The reference the column where the formula column is. So if you look in the UI and it is the third from the top, you can get the value using result[0].getValue(columns[2])
This solution is dependent on the order of rows not changing.
Also if your saved search has labels for the Formulas, you can just use the labels as the field id.
I need to add multiple values (ID fields of another custom list) to a Multiple Lookup field using Sp-services.
What is the correct format of the data to be used ?
I have tried like ( 5,9,6 ) but only selecting the first item.
I am not quite sure why do you want to do this, because these items you will add - they can't be saved as values, because there is a relationship between the column and lookup list, i.e. if you have Lookup column to the List1 and you add a new value from the List2 with id 99 and save, it will save the reference to the list item with id 99 in the List1.
but if anything, it is possible, this is how I am appending multiple lookup selected values:
var lines = additionalTechnologies.split(';#');
$.each(lines, function (index) {
if (lines[index].length < 3) {
$("select[title='Additional Technologies selected values']:first").append("<option value=" + lines[index] + " title=" + lines[index + 1] + ">" + lines[index + 1] + "</option>");
$("select[title='Additional Technologies possible values'] option[value=" + lines[index] + "]").remove();
}
});
and remove them from the all items list. just do it vice versa.
I have found a way to do it.
// "list1Id" contains the array of LIST1 ID fields that you want to add...
// "MULTIPLELOOKUPFIELD" is the multiple lookup field in the LIST2...
var multipleLookupValue ="";
for(i = 0; i < list1Id.length ; i++)
{
multipleLookupValue = multipleLookupValue + list1Id[i]+";#data;#";
}
var method = "UpdateListItems";
$().SPServices({
operation: method,
async: false,
batchCmd: "New",
listName: "LIST2" ,
valuepairs: [["MULTIPLELOOKUPFIELD",multipleLookupValue]],
completefunc: function (xData, Status) {
//alert("Added new item to LIST2 list");
}
});
May be it will help someone...
Let's say I have two HBase cells:
x:y
x:z
How do I do the equivalent of this SQL:
SELECT * FROM some_table WHERE x_y = ? AND x_z = ?
This is the (Groovy) code I have for generating the basic filters:
static SingleColumnValueFilter makeColumnFilter(String family, String qualifier, String expectedValue) {
new SingleColumnValueFilter (
Bytes.toBytes(family),
Bytes.toBytes(qualifier),
CompareFilter.CompareOp.valueOf('EQUAL'),
new SubstringComparator(expectedValue))
}
def filterz = filters.collect {
makeColumnFilter(it.family, it.qualifier, it.expectedValue)
}
def fl = new FilterList(filterz)
def scan = new Scan()
scan.setFilter(fl)
def family = 'x'.bytes
t.getScanner(scan).each {
println "${Bytes.toString(it.getValue(family, 'y'.bytes))}"
count++
}
The print statement shows nothing but nulls even though I'm passing in x for the family value and y/z for the qualifiers. It appears to not be filtering the values. What am I doing wrong?
You need to filter the rows if the column is not found using setFilterIfMissing.
Change the makeColumnFilter to :
static SingleColumnValueFilter makeColumnFilter(String family, String qualifier, String expectedValue) {
def colFilter = new SingleColumnValueFilter (
Bytes.toBytes(family),
Bytes.toBytes(qualifier),
CompareFilter.CompareOp.valueOf('EQUAL'),
new SubstringComparator(expectedValue))
colFilter.setFilterIfMissing(true)
colFilter
}
I think SingleColumnValueExcludeFilter should do the job.
Scan scan = new Scan();
SingleColumnValueExcludeFilter singleColumnValueFilterY = new SingleColumnValueExcludeFilter("x".getBytes(),
"y".getBytes(), CompareOp.EQUAL, new BinaryComparator("valueY".getBytes()), true, true);
SingleColumnValueExcludeFilter singleColumnValueFilterZ = new SingleColumnValueExcludeFilter("x".getBytes(),
"z".getBytes(), CompareOp.EQUAL, new BinaryComparator("valueZ".getBytes()), true, true);
FilterList filterList = new FilterList(Operator.MUST_PASS_ALL);
filterList.addFilter(singleColumnValueFilterX);
filterList.addFilter(singleColumnValueFilterY);
scan.setFilter(filterList);
More detailed documentation on HBase filters could be found here.
Hope this will help.
I need to set null value i.e., "" value on a control.But I am facing exception as below
"Cannot perform 'SetProperty of Text with value ""' on the control. Additional Details:
TechnologyName: 'Web'
ControlType: 'Edit'
Id: 'ctl00_ctl00_Content_PlanContent_ucParentDeferralRule_txtAutoEnrollAmt'
Name: 'ctl00$ctl00$Content$PlanContent$ucParentDeferralRule$txtAutoEnrollAmt'
TagName: 'INPUT'"
and the code is like,
Control.Text = "";
So if we have:
public HtmlEdit EditField()
{
HtmlEdit control = new HtmlEdit(GlobalVariable.browser);
control.SearchProperties["id"] = "ctl00_ctl00_Content_PlanContent_ucParentDeferralRule_txtAutoEnrollPercent";
return control;
}
we should be able to set the value as you did (using EditField().Text = String.Empty). The fact that we can't means that there's a restriction on that field that won't accept that value as an input. Check the code to see if it's restricted to numerical values, for example, or if the value.length cannot be < 1, etc.
I have a column in my dgrid that uses a digit.form.Select.
var gl = {};
gl.coverTypeEditorData = [{label: "C", value: "C"},
{label: "F", value: "F"},
{label: "G", value: "G"},
{label: "S", value: "S"},
{label: "P", value: "P"}];
...
,editor({
'label': 'Type',
'field': 'TYPE',
'editor': Select,
'editorArgs': {
options: gl.coverTypeEditorData
}
}
)
The select drop down displays the correct value, but when it closes the value in the cell gets changed to whatever value was last chosen.
Row 1: Change the value to S.
Row 2: Has value C. I select the dd but do not change the value. Display changes to S. Change row event does not fire. The cell has a S displaying but its actual value is C, which will be the selected value if I open the drop down again.
What do I need to add to get the cell to display the correct value?
The answer was simple: The two constructors are not equivalent.
,editor({
'label': 'Type',
'field': 'TYPE',
'editorArgs': {
style: "width:35px;border: 1px solid green;",
options: gl.coverTypeEditorData
}
}, Select, 'click'
)
var args = targetColumn.editorArgs
targetColumn.editorArgs = function(){
args['options'] = lang.clone(data);
return args;
}
because dgrid sharing editorArgs
try lang.clone();