Search/Filter JStree by metadata - search

I was wondering if there was anything in place in jstree to filter a tree based on metadata.
Something along the lines of
var v = $('#treeSearch').val();
$(element).jstree(true).search(v);
but instead of searching based off the name I would want to search based off of some metadata value x.
var mData = $('#mDataSearch').val();
//Search code
Thanks for your help

Related

How to get source list types of particular list/record field?

Here is I have two entity custom fields with list/record type,
custom_dev_j15 entity field has a custom source list (eg: one, two, three, four, etc)
custom_qa_v93 entity field has a standard source list as an object (eg: customer )
I've two vendor entity custom fields as stated in screenshots of question,
custentity473 --> customer is selected as list source
custentity474 --> custom_dev_j15_m_list as selected as list source ( which is custom list)
Here is snippet that i used to get the options of these fields,
// Snippet
var fieldDetails = {};
var record = nlapiCreateRecord("Vendor");
var field = record.getField("custentity473");
var selectoptions = field.getSelectOptions();
for ( var i in selectOptions) {
var Option = {
id : selectOptions[i].getId(),
label : selectOptions[i].getText()
}
Options.push(Option);
}
fieldDetail["options"] = Options;
But my need is to get source list information like name of the list source (customer or custom_dev_j15_m_list) via suitescript
any idea on how to get this information?
Thanks in advance
I'm not sure I understand this question for what you're trying to do.
In NetSuite almost always, you accommodate to the source list types because you know that's the type, and if you need something else (e.g. a selection which is a combination/or custom selection you'll use a scripted field)
Perhaps you can expand on your use case, and then we can help you further?

Get the label of a MathJax equation

How can I get the label of an equation? I'm attempting to reprocess an equation with a label, but I have to delete the label from MathJax.Extension["TeX/AMSmath"].labels first, for which the label must be known...
I know I can scan through the source text for the label MathJax.Hub.getAllJax("mathDiv")[0}.SourceElement().find("\label(") (...), but this seems needlessly complicated. Is there a better way?
There's no built-in API for this.
If you don't need to keep labels, then the reset in the comment above is probably the best way to go about it:
MathJax.Extension["TeX/AMSmath"].labels = {}
A quick and dirty way to get the IDs is to leverage the fact that they end up in the output. So you can just get all the IDs in the output, e.g.,
const math = MathJax.Hub.getAllJax()[0];
const nodesWithIds = document.getElementById(math.root.inputID).previousSibling.querySelectorAll('[id]');
const ids = [];
for (node of nodesWithIds) ids.push(node.id);
A cleaner and perhaps conceptually easier way would be to leverage MathML (which is essentially the internal format): the \label{} always ends up on an mlabeledtr. The trouble is that you'd have to re-parse that, e.g.,
const temp = document.createElement('span');
temp.innerHTML = math.root.toMathML();
const nodesWithIds = temp.querySelectorAll('mlabeledtr [id]');
const ids = [];
for (node of nodesWithIds) ids.push(node.id);
This will make sure the array only has relevant IDs in them (and the contents of the nodes should correspond to \label{}.
I suppose with helper libraries it might be easier to dive into the math.root object directly and look for IDs recursively (in its data key).

Suitescript nlapiSearchRecord cant load custom record

I've got what is probably a simple issue, but cant seem to find an answer to it.
I have a custom record, with an list field containing the item records in the account.
Whenever I run the script it returns the 2 rows in the custom record, rather than the specific record im trying to source.
I know its list is just the items list, but when i try '10' as the internal id of the specific item record it throws an error.
nlobjSearchFilter('custrecord_pm_int_inventory_item',null,'is','10');
it throws an error, i have seen similar posts on stackoverflow for this, but not exactly trying to load a custom record that has a list field of item
// if inventory item has been found, check to see if it exists in the item tracking record
var filt = [];
filt[0] = new nlobjSearchFilter('custrecord_tc_int_inventory_item',null,'is','88999 shipping');
var cols = [];
cols[0] = new nlobjSearchColumn('internalid');
cols[1] = new nlobjSearchColumn('custrecord_tc_int_inventory_item');
var search = nlapiSearchRecord('customrecord_tc_int_item_tracking',null,filt,cols);
Hopefully im just missing something simple, but i cant seem to load the record, any ideas greatly appreciated
You gotta use anyof operator and pass an array, here's how it should look:
// if inventory item has been found, check to see if it exists in the item tracking record
var filt = [];
filt[0] = new nlobjSearchFilter('custrecord_tc_int_inventory_item',null,'anyof',['10']);
var cols = [];
cols[0] = new nlobjSearchColumn('internalid');
cols[1] = new nlobjSearchColumn('custrecord_tc_int_inventory_item');
var search = nlapiSearchRecord('customrecord_tc_int_item_tracking',null,filt,cols);

Getting value of key from Web Content Display Portlet

I got a requirement. I have added two text fields Value and Key from structure in Web Content Display portlet.
right now in the portlet i am getting value from hard code like below.
BasicModel model = (BasicModel)requestContext.getFlowScope().get("BasicModel");
if(model == null){
model = new BasicModel();
}
model.setEmployeeId("AB1223344S");
model.setHireDate("01-Jan-2000");
model.setNiNumber("AB123456S");
model.setDateOfBirth("12-Dec-1980");
model.setBasicForm(new BasicDetailsForm());
}
but what i want is to get the value of each attribute from web content. Like, If i have given lfr.intel.empid as key and ABSD1822D as value in the added web content structure field like this.
and we can fetch the value of key like this.
model.setEmployeeId(lfr.intel.empid);
You can write a custom function for this which passes the key to that function, now that function will use the JournalArticleLocalServiceUtil API to get respective value from the DB.
Now you need to find How to fetch values from JournalArticleLocalServiceUtil, which you can google or this link can help you.
Thanks.
Try this, assuming that you could get the JournalArticle object, I've done it using the resourcePrimKey
long resourcePrimKey = 12345; //hard coded the resourcePrimKey
JournalArticle article = JournalArticleLocalServiceUtil.getLatestArticle(resourcePrimKey);
com.liferay.portal.kernel.xml.Document document = SAXReaderUtil.read(article.getContentByLocale("en_US"));
Node keyNode = document.selectSingleNode("/root/dynamic-element[#name='Key']/dynamic-content");
String key = keyNode.getStringValue();
Node valueNode = document.selectSingleNode("/root/dynamic-element[#name='Value']/dynamic-content");
String value = valueNode .getStringValue();

JSON.Net SerializeXnode excluding certain nodes

I have a xml string that i'm trying to convert to JSON using JSON.Net. The problem is that i want only certain part of this xml in my JSON string. Below is the code i use and what i need.
var x = XDocument.Parse(xmlString);
var json = JsonConvert.SerializeXNode(x);
This will convert the whole doc. This is how json string looks like in a JSON Viewer
What i want is ONLY the table (The Arrowed one in image 1) and its descendants to be inside string json.
Is it possible? How to achieve it? Can i use a custom ContractResolver with SerializeXnode?
You've got an XDocument, so why not simply select the part you want and then serialize just that part?
Try something like this:
var doc = XDocument.Parse(xmlString);
var table = doc.XPathSelectElement("//table[#class=\"form\"]");
var json = JsonConvert.SerializeXNode(table);
Note that XPathSelectElement is an extension method, so you will need using System.Xml.XPath; at the top of your code if you don't already have it.
EDIT
You can do it without XPath like this:
var doc = XDocument.Parse(xmlString);
var table = root.Descendants(XName.Get("table"))
.Where(e => e.Attributes(XName.Get("class"))
.Select(a => a.Value)
.FirstOrDefault() == "form")
.First();
var json = JsonConvert.SerializeXNode(table);
Both approaches give the same results, the table plus all descendants.

Resources