How can I determine in which period am I hover in edit mode in ganttResource anychart 8.2.0 - gantt-chart

I'm creating a POC for a Gantt project for my company. I'm using the Resource Gantt from Anychart version 8.2.0. I'm trying to determine in which period am I, in order to set a custom tooltip. If I'm not in edit mode my code works, but if in edit mode, it doesn't! I can't determine in which period we are, because the periodIndex is undefined. Can anyone help me?
My custom tooltip code:
//custom timeLine Tooltip
timeLine.tooltip().useHtml(true);
timeLine.tooltip().format(function (e) {
var tooltip = '';
var startDate;
var endDate;
var item = e.item;
var parentElement = item.getParent();
if (parentElement !== null ) {
tooltip = 'Project: ' + parentElement.get('name') + '<br>';
} else {
tooltip = '';
}
if (e.periodIndex !== undefined){
startDate = e.period.start;
endDate = e.period.end;
tooltip = tooltip + 'Period Id: ' + e.period.id + '<br>';
tooltip = tooltip + 'Start Date: ' + startDate + '<br>' + 'End Date: ' + endDate;
} else {
var periodsArr = item.get('periods');
startDate = periodsArr[0].start;
endDate = periodsArr[periodsArr.length-1].end;
tooltip = tooltip + 'From ' + startDate + ' to ' + endDate;
}
return tooltip;
});
I have a sample in here: https://jsfiddle.net/migrafik/yobu0t6y/6/
Thanks.

Unfortunately, when the LiveEdit mode is enabled, you hover the period along with editing thumbs and other elements which implement this feature. That's why the period info is not available. So, with the current version of library 8.2.1 this cannot be done. I will suggest this improvement to our dev team and probably in future releases, the period info will become available. I will notify you about the ETA and when the improvement gets released.

Related

SharePoint Columns Don't Update After Successful JSOM update() call

I have a workflow that copies items from a standard Calendar list to a second standard Calendar list. But the copies contain less details about any given calendar item than the original. This works just fine except that the Start Time and End Time fields get copied over in UTC time and we need those times displayed in the user's local time zone (we have employees all over the world, so it can't be a static adjustment). I am aware that SharePoint stores all Dates/Times as UTC and I get why.
My solution to this problem is to (in the main calendar) create two hidden Date/Time columns that I would populate with the dates/times from the EventDate and EndDate Calendar columns (the UTC values), but these new values would be corrected for the time zone offset using the SharePoint Client Side Object Model (using JS). Then my workflow would copy these corrected dates/times over to the second calendar.
The following code appears to work. My success handlers are getting called for each iteration of the list items and my logged output shows all the correct values. However, after the code runs, the two Date fields that are supposed to have been updated/set on each item by the code remain blank.
<script src="/_layouts/15/sp.runtime.js"></script>
<script src="/_layouts/15/sp.js"></script>
<script>
var siteUrl = "https://duckcreek.sharepoint.com/sites/DCU";
function loadListItems(siteUrl) {
var ctx = new SP.ClientContext(siteUrl);
var oList = ctx.get_web().get_lists().getByTitle("Master Calendar");
var camlQuery = new SP.CamlQuery();
this.collListItem = oList.getItems(camlQuery);
// EventDate and EndDate are the pre-defined fields (from the Event
// content type) that represent the event start and end date / times
// CorrectedStartDateTime and CorrectedEndDateTime are pre-existing
// Date / Time fields in the list.
ctx.load(collListItem,
"Include(Id, DisplayName, EventDate, EndDate, CorrectedStartDateTime, CorrectedEndDateTime)");
ctx.executeQueryAsync(
Function.createDelegate(this, this.onLoadListItemsSucceeded),
Function.createDelegate(this, this.onLoadListItemsFailed));
}
function onLoadListItemsSucceeded(sender, args) {
var ctx = new SP.ClientContext(siteUrl);
var oList = ctx.get_web().get_lists().getByTitle("Master Calendar");
var listItemInfo = "";
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
// List is loaded. Enumerate the list items
let oListItem = listItemEnumerator.get_current();
// Get the Calendar item Start and End dates as stored in SharePoint (UTC)
let startDateString = oListItem.get_item("EventDate").toString();
let endDateString = oListItem.get_item("EndDate").toString();
// Get the GMT time zone offset
let startDateOffsetHours = parseInt(startDateString.split("GMT-")[1]) / 100;
let endDateOffsetHours = parseInt(endDateString.split("GMT-")[1]) / 100;
// Create new dates that are the same as the originals
let resultStartDate = new Date(startDateString);
let resultEndDate = new Date(endDateString);
// Adjust the new dates to be correct for the local time zone based on the UTC offset
resultStartDate.setHours(resultStartDate.getHours() + startDateOffsetHours);
resultEndDate.setHours(resultEndDate.getHours() + endDateOffsetHours);
// Update the two placeholder fields in the current list item with the corrected dates
oListItem.set_item("CorrectedStartDateTime", resultStartDate);
oListItem.set_item("CorrectedEndDateTime", resultEndDate);
// Update SharePoint
oListItem.update();
ctx.executeQueryAsync(
Function.createDelegate(this, this.onSetCorrectDateTimesSucceeded),
Function.createDelegate(this, this.onSetCorrectDateTimesFailed)
);
// This is just for diagnostics, but it does show the correct data.
// And since we are using .get_item() here, it would seem that we
// are pulling the correct data out of SharePoint, but the two "Corrected"
// fields remain empty after this function completes successfully.
listItemInfo += "\nDisplay name: " + oListItem.get_displayName() +
"\n\tEventDate: " + oListItem.get_item("EventDate") +
"\n\tEndDate: " + oListItem.get_item("EndDate") +
"\n\t\tCorrectedStartDateTime: " + oListItem.get_item("CorrectedStartDateTime") +
"\n\t\tCorrectedEndDateTime: " + oListItem.get_item("CorrectedEndDateTime") +
"\n--------------------------------------------------------------------------------";
}
console.log(listItemInfo.toString());
}
function onLoadListItemsFailed(sender, args) {
console.log("Request failed!" + args.get_message() + "\n" + args.get_stackTrace());
}
function onSetCorrectDateTimesSucceeded() {
console.log("Item updated!");
}
function onSetCorrectDateTimesFailed(sender, args) {
console.log("Request failed!" + args.get_message() + "\n" + args.get_stackTrace());
}
loadListItems(siteUrl);
</script>​​​
And, here is one of the records that the code produces (it actually produces one of the following for each of the items on the first calendar as it should):
Display name: NEW TEST
EventDate: Mon Dec 31 2018 19:00:00 GMT-0500 (Eastern Standard Time)
EndDate: Tue Jan 01 2019 18:59:00 GMT-0500 (Eastern Standard Time)
CorrectedStartDateTime: Tue Jan 01 2019 00:00:00 GMT-0500 (Eastern Standard Time)
CorrectedEndDateTime: Tue Jan 01 2019 23:59:00 GMT-0500 (Eastern Standard Time)
--------------------------------------------------------------------------------
However, the calendar items don't get the two "corrected" fields updated:
Simple answer
You recreate the SP.ClientContext in the onLoadListItemsSucceeded function, so you don't actually call update for the original list item. Save it in a variable and reuse it instead.
Complete code
<script src="/_layouts/15/sp.runtime.js"></script>
<script src="/_layouts/15/sp.js"></script>
<script>
var siteUrl = "https://duckcreek.sharepoint.com/sites/DCU";
var ctx;
function loadListItems(siteUrl) {
ctx = new SP.ClientContext(siteUrl);
var oList = ctx.get_web().get_lists().getByTitle("Master Calendar");
var camlQuery = new SP.CamlQuery();
this.collListItem = oList.getItems(camlQuery);
// EventDate and EndDate are the pre-defined fields (from the Event
// content type) that represent the event start and end date / times
// CorrectedStartDateTime and CorrectedEndDateTime are pre-existing
// Date / Time fields in the list.
ctx.load(collListItem,
"Include(Id, DisplayName, EventDate, EndDate, CorrectedStartDateTime, CorrectedEndDateTime)");
ctx.executeQueryAsync(
Function.createDelegate(this, this.onLoadListItemsSucceeded),
Function.createDelegate(this, this.onLoadListItemsFailed));
}
function onLoadListItemsSucceeded(sender, args) {
var oList = ctx.get_web().get_lists().getByTitle("Master Calendar");
var listItemInfo = "";
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
// List is loaded. Enumerate the list items
let oListItem = listItemEnumerator.get_current();
// Get the Calendar item Start and End dates as stored in SharePoint (UTC)
let startDateString = oListItem.get_item("EventDate").toString();
let endDateString = oListItem.get_item("EndDate").toString();
// Get the GMT time zone offset
let startDateOffsetHours = parseInt(startDateString.split("GMT-")[1]) / 100;
let endDateOffsetHours = parseInt(endDateString.split("GMT-")[1]) / 100;
// Create new dates that are the same as the originals
let resultStartDate = new Date(startDateString);
let resultEndDate = new Date(endDateString);
// Adjust the new dates to be correct for the local time zone based on the UTC offset
resultStartDate.setHours(resultStartDate.getHours() + startDateOffsetHours);
resultEndDate.setHours(resultEndDate.getHours() + endDateOffsetHours);
// Update the two placeholder fields in the current list item with the corrected dates
oListItem.set_item("CorrectedStartDateTime", resultStartDate);
oListItem.set_item("CorrectedEndDateTime", resultEndDate);
// Update SharePoint
oListItem.update();
ctx.executeQueryAsync(
Function.createDelegate(this, this.onSetCorrectDateTimesSucceeded),
Function.createDelegate(this, this.onSetCorrectDateTimesFailed)
);
// This is just for diagnostics, but it does show the correct data.
// And since we are using .get_item() here, it would seem that we
// are pulling the correct data out of SharePoint, but the two "Corrected"
// fields remain empty after this function completes successfully.
listItemInfo += "\nDisplay name: " + oListItem.get_displayName() +
"\n\tEventDate: " + oListItem.get_item("EventDate") +
"\n\tEndDate: " + oListItem.get_item("EndDate") +
"\n\t\tCorrectedStartDateTime: " + oListItem.get_item("CorrectedStartDateTime") +
"\n\t\tCorrectedEndDateTime: " + oListItem.get_item("CorrectedEndDateTime") +
"\n--------------------------------------------------------------------------------";
}
console.log(listItemInfo.toString());
}
function onLoadListItemsFailed(sender, args) {
console.log("Request failed!" + args.get_message() + "\n" + args.get_stackTrace());
}
function onSetCorrectDateTimesSucceeded() {
console.log("Item updated!");
}
function onSetCorrectDateTimesFailed(sender, args) {
console.log("Request failed!" + args.get_message() + "\n" + args.get_stackTrace());
}
loadListItems(siteUrl);
</script>​​​
Additional notes
Time zones offsets can be negative(-) or positive (+), so these lines are probably incomplete
// Get the GMT time zone offset
let startDateOffsetHours = parseInt(startDateString.split("GMT-")[1]) / 100;
let endDateOffsetHours = parseInt(endDateString.split("GMT-")[1]) / 100;

RangeError Maximum call stack size exceeded on Creating Sales Order

We are developing a client script that will auto update the rate or unit price (*this is a custom column), but it throws an error and I think its because if we change the rate it will auto update the unit price and after the unit price has been updated it will update the rate also, so on and so on until it reach the maximum call stack, We are looking for any workaround for this not to happen, please see my code below. Thanks
function fieldChanged(type, name, linenum)
{
var context = nlapiGetContext();
var user = context.getUser();
var execution = context.getExecutionContext();
try {
switch (name) {
case "custcol_cqwst_po_uprice":
if (execution == "userinterface") {
var qty = nlapiGetCurrentLineItemValue('item', 'quantity');
var taxCode = nlapiGetCurrentLineItemValue('item', 'taxcode');
if (!isNullOrEmpty(taxCode) && !isNullOrEmpty(qty)) {
var taxRate = nlapiGetCurrentLineItemValue('item', 'taxrate1');
var unitprice = nlapiGetCurrentLineItemValue('item', 'custcol_cqwst_po_uprice');
var vatRate = 1 + ((taxRate.replace('%', '')) / 100);
var unitRate = unitprice / vatRate;
nlapiSetCurrentLineItemValue('item', 'rate', unitRate);
}
}
break;
//case "taxcode":
//break;
case "rate":
if (execution == "userinterface") {
var qty = nlapiGetCurrentLineItemValue('item', 'quantity');
var taxCode = nlapiGetCurrentLineItemValue('item', 'taxcode');
if (!isNullOrEmpty(taxCode) && !isNullOrEmpty(qty)) {
var taxRate = nlapiGetCurrentLineItemValue('item', 'taxrate1');
var rate = nlapiGetCurrentLineItemValue('item', 'rate');
var vatRate = 1 + ((taxRate.replace('%', '')) / 100);
var unitPrice = rate * vatRate;
nlapiSetCurrentLineItemValue('item', 'custcol_cqwst_po_uprice', unitPrice);
nlapiLogExecution('debug', "Rate Value", "Rate: " + rate + " Vat Rate: " + vatRate + " Unit Price: " + unitPrice + " Execution: " + execution);
}
}
break;
}
}
catch (ex) {
alert("A scripting problem occurred during the onFieldChange event please inform an administrator quoting the following error: " + ((ex instanceof nlobjError) ? ex.getCode() + '\n' + ex.getDetails() : ex.toString()));
}
}
nlapiSetCurrentLineItemValues() has a fourth paramater called firefieldchanged which can be set to false to prevent exactly this issue
Using the Fire Field Changed Parameter
When creating scripts that provide the ability to watch a field for a
change, and then write back to the field that changed, a risk of
creating an infinite loop exists as follows:
The Client script watches for fieldA to change.
fieldA changes.
The script writes to fieldA, causing the Field Changed event to fire,
returning the code to step 2, and this loop repeats indefinitely.
To prevent this looping behavior, you can set the optional
firefieldchanged parameter in your client scripts.
The firefieldchanged parameter is available for all write functions.
If set to true, the parameter causes any field changed events to fire
as normal. This is the default setting. If set to false, field changed
events are NOT fired.
https://system.netsuite.com/app/help/helpcenter.nl?fid=section_N3042487.html#bridgehead_N3050839

How to create Purchase Order in Netsuite with ScriptSuite?

I am new to Netsuite and I was asked to perform a script that was launched from an application programmed in java. The script with a function to generate a Purchase Order in Netsuite and other function to list the Purchase Order created earlier. It turns out that for this I am using the api SuiteScript but when creating the Purchase Order run the java application and launches the script but it gives the following error:
Aug 03, 2015 2:49:00 PM com.gargoylesoftware.htmlunit.WebClient printContentIfNecessary
INFO: {"error": {"code": "user_error", "message": "Please enter value (s) for: Vendor"}}
Javascript function to create is:
function CreatePurchase_Orders(datain){
var output = '';
nlapiLogExecution('DEBUG','createRecord','ingreso la consulta' ) ;
nlapiLogExecution('DEBUG','createRecord', 'Ingresa: '+ datain);
//var msg = validateTimeBills(datain);
var msg = null;
if (msg){
var err = new Object();
err.status = "failed";
err.message= msg;
return err;
}
var Purchase_Orders = datain.Purchase_Order;
nlapiLogExecution('DEBUG','createRecord', 'obtuvo el objeto: '+ Purchase_Orders);
for (var Purchase_Orderobject in Purchase_Orders){
var Purchase_Order = Purchase_Orders[Purchase_Orderobject];
var transdate = Purchase_Order.Transdate;
var Form = Purchase_Order.Form;
var Vendor = Purchase_Order.Vendor;
var Currency = Purchase_Order.Currency;
var Item = Purchase_Order.Item;
nlapiLogExecution('DEBUG','campos','transdate: '+ transdate+'/Form: '+Form + ' /Vendor: ' + Vendor + ' /Currency: ' + Currency
+ ' /Item: ' + Item);
var Purchase_Order = nlapiCreateRecord('purchaseorder');
var nlobjAssistant = nlapiCreateAssistant ( 'asistente' , false ) ;
var Purchase_Orderid = 1;//nlapiSubmitRecord( Purchase_Order , true, true);
if(Purchase_Order){
nlapiLogExecution('DEBUG', 'Purchase_Order ' + Purchase_Orderid + ' successfully created', '');
nlapiLogExecution('DEBUG', 'createRecord', 'creo el record');
}
Purchase_Order.setFieldValue('transdate', transdate);
Purchase_Order.setFieldValue('inpt_customform1', Form);
Purchase_Order.setFieldValue('vendor', Vendor);
Purchase_Order.setFieldValue('inpt_currency7', Currency);
Purchase_Order.setFieldValue('inpt_item', Item);
Purchase_Order.setFieldText('quantity_formattedValue', '1');
Purchase_Order.setFieldText('rate_formattedValue', '1');
Purchase_Order.setFieldText('amount_formattedValue', '1');
Purchase_Order.setFieldText('inpt_taxcode', 'VAT_MX:UNDEF_MX');
Purchase_Order.setFieldText('grossamt_formattedValue', '1');
Purchase_Order.setFieldText('tax1amt_formattedValue', '0');
Purchase_Order.setFieldText('expectedreceiptdate', '24/6/2015');
//var Purchase_Orderid = 1;//nlapiSubmitRecord( Purchase_Order , true, true);
var submitRecord = nlapiSubmitRecord(Purchase_Order);//,true);
nlapiLogExecution('DEBUG', 'submirRecord ' + submitRecord);
}
var mesg = new Object();
mesg.status = "OK";
mesg.message= nlobjAssistant.getAllFields();
return mesg;
}
And the function code in Java is:
WebClient client = new WebClient(BrowserVersion.FIREFOX_31);
client.getOptions().setJavaScriptEnabled(false);
client.getOptions().setThrowExceptionOnScriptError(false);
WebRequest requestSettings = new WebRequest(new URL(url),HttpMethod.POST);
requestSettings.setAdditionalHeader("Host", "rest.na1.netsuite.com");
requestSettings.setAdditionalHeader("User-Agent", "SuiteScript-Call");
requestSettings.setAdditionalHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
requestSettings.setAdditionalHeader("Accept-Language", " es-cl,es;q=0.8,en-us;q=0.5,en;q=0.3");
requestSettings.setAdditionalHeader("Accept-Encoding", "gzip, deflate");
requestSettings.setAdditionalHeader("Content-Type", "application/json");
requestSettings.setAdditionalHeader("Pragma", "no-cache");
requestSettings.setAdditionalHeader("Cache-Control", "no-cache");
requestSettings.setAdditionalHeader("Referer", "http://localhost:8084");
requestSettings.setAdditionalHeader("Cookie", "");
requestSettings.setAdditionalHeader("Connection", "keep-alive");
requestSettings.setAdditionalHeader("Authorization", "NLAuth nlauth_account=" + account + ", nlauth_email=" + mail + ", nlauth_signature=" + pass + ", nlauth_role=" + role + "");
Gson gson = new Gson();
//objeto llenado estaticamente de forma momentanea, se debe leer desde archivo externo
Purchase_Order purchaseOrder = new Purchase_Order("25/06/2015","formTest","vendorTest","CurrencyTest","itemTest");
String cuerpo = gson.toJson(purchaseOrder);
System.out.println(cuerpo);
// Set the request parameters
requestSettings.setRequestBody(cuerpo);
Page page = client.getPage(requestSettings);
WebResponse response = page.getWebResponse();
String json = response.getContentAsString();
System.out.println(json);
With this javascript function you should create me a record Purchase Order but I can not find the error and the solution if someone could please help me I would appreciate it a lot.
PS: if you have to create a customized form could tell me how?
thanks!
Here are some points :
As your error message says Please enter value (s) for: Vendor, you're missing the value for vendor field, which is mandatory. In your piece of code you're passing wrong internalid value for vendor. You should use entity instead of vendor
Purchase_Order.setFieldValue('entity', Vendor); // where vendor is the internal id of the vendor record
For setting custom form you can use
Purchase_Order.setFieldValue('customform', Form); // where Form is the id of the custom form
I also noticed that you're setting some values in purchase order which I suspect are to be a kind of custom one. If that is the case, then your custom field internal id should be prefixed with custbody.
For all the standard fields internal id you can refer to the Suite script Records Browser.

SharePoint 2013 - Get SPListItem versions via REST

I have a SharePoint 2013 List with versioning enabled.
I need to to get SPListItem versions list via REST.
I can get SPListItem by that request: http://spbreportportal/Projects/_api/lists/getbytitle('Projects')/Items(1)
But I can't find in documentation and in response how to retrieve all versions of this item.
Is it possible?
It does not seem possible to get versions for a List Item via REST/CSOM APIs, but there are alternative options
Using Versions.aspx application page
The idea is to perform a get request to Versions page: http://<server>/<site>/_layouts/versions.aspx?list={litsID}&ID=<itemID>
function getItemVersions(url,listId,itemId,success)
{
var versionsUrl = url + '/_layouts/versions.aspx?list=' + listId + '&ID=' + itemId;
$.get( versionsUrl, function( data ) {
var versionEntries = parseVersionList(data);
success(versionEntries);
});
}
function parseVersionList(data){
var entries = {};
var versionList = $(data).find('table.ms-settingsframe');
versionList.find('tbody > tr').each(function(i){
if(i > 0 && (i-1) % 2 == 0) {
var verRow = $(this); //get version row
var propsRow = verRow.next(); //get properties row
var versionLabel = verRow.find('td:first').html().trim();
entries[versionLabel] = {};
//extract item properties from propsRow goes here
//...
}
});
return entries;
}
//Usage
var webUrl = _spPageContextInfo.webAbsoluteUrl;
var listId = _spPageContextInfo.pageListId;
var listItemId = 1;
getItemVersions(webUrl,listId,listItemId,function(versionEntries){
console.log(versionEntries);
});
Using Lists SharePoint Web Services
Another option would be to utilize Lists SharePoint Web Services that exposes Lists.GetVersionCollection Method to return version information for the specified field in a SharePoint list
SPServices example:
$().SPServices({
operation: "GetVersionCollection",
async: false,
strlistID: "Projects",
strlistItemID: 1,
strFieldName: "Description",
completefunc: function (xData, Status) {
$(xData.responseText).find("Version").each(function(i) {
console.log("Name: " + $(this).attr("Description") + " Modified: " + $(this).attr("Modified"));
});
}
});
Note: This doesn't seem to work in 2013. I have verified this working in SharePoint Online and it may work in 2016+ but I have not verified the latter.
The situation may have changed since this question was originally posted, but it is now possible to use the REST API to get version history for any list/library item:
https://url/to/site/_api/web/Lists/getbytitle('MyListName')/items(ITEMID)/versions
This will return a series of results for the current version and all past versions, with the item's column values from each version.
As with other REST endpoints, you can use $select, $filter, etc. to further manipulate the results.
In the REST API, you can select the property OData__UIVersionString. It also supports OData__ModerationStatus
Ex:
GET http://site url/_api/web/lists/GetByTitle(‘Test')/items(item id)?$select=OData__UIVersionString,OData__ModerationStatus
More infos : https://msdn.microsoft.com/en-us/library/office/dn292552.aspx
It's not a solution to get all the versions or a specific version, but it's more info on the version.
To add to #Vadim Gremyachev's Excellent answer to use "GetversionCollection": This interface can also be reached using old school SOAP. Unfortunately it only returns one field at the time (so we use a lot of calls ...). The C# snippet is below.
//https://blogs.msdn.microsoft.com/pinch-perfect/2016/06/04/sharepoint-web-services-read-version-history-for-column-changes/
//http://www.indy.gov/eGov/City/DCE/Permits/Signs/_vti_bin/lists.asmx?op=GetVersionCollection
//https://www.codeproject.com/Articles/26338/Using-the-GetListItems-GetVersionCollection-and-Up
string strSite =
string strListGuid =
string strListItemID =
string strFieldName = "Title" // or some other field name
string requestXML = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>" +
"<soap:Body>" +
"<GetVersionCollection xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" +
"<strlistID>"+ strListGuid + "</strlistID><strlistItemID>" + strListItemID + "</strlistItemID>" +
"<strFieldName>"+ strFieldName +"</strFieldName>" +
"</GetVersionCollection>" +
"</soap:Body>" +
"</soap:Envelope>";
object xmlRequestObj = Activator.CreateInstance(Type.GetTypeFromProgID("Microsoft.XMLHTTP"));
MSXML2.XMLHTTP xmlRequest = (MSXML2.XMLHTTP)xmlRequestObj;
xmlRequest.open("Get", strSite + "/_vti_bin/Lists.asmx", false, null, null);
xmlRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlRequest.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/GetVersionCollection");
xmlRequest.send(requestXML);
string responseText = xmlRequest.responseText;
To add more information reagrding on how to obtain all version history from a SharePoint list:
//Get ID of the Dossier in SP list
strID = items(i - 1).getAttribute("ows_ID")
Debug.Print strID
//Get all Versions of the ID in SP list as a XML
URL1: https://path to site collection/_vti_bin/owssvr.dll?Cmd=Display&List={LIstID}&XMLDATA=TRUE&Query=*&IncludeVersions=TRUE
XDoc3.Load (URL1 & "&FilterField1=ID&FilterOp1=eq&FilterValue1=" & strID)
Set Item = XDoc3.SelectNodes("//rs:data/*")
Set temp3 = XDoc3.SelectNodes("//rs:data/*")

How do I pass multiple datasets to my view in sailsjs?

I want to be able to pass multiple data sets to my view. Here is how I am currently doing it in my controller:
transactions: function (req, res) {
var queryexpenses = 'select * from expense order by name';
Expense.query(queryexpenses, function (err, expense) {
this.expenses = expense;
});
if (req.param('filter')) {
var where = 'where fk_expense = ' + req.param('expensefilter');
where += ' and datePosted > "' + req.param('yearfilter') + '-01-01" ';
where += ' and datePosted < "' + req.param('yearfilter') + '-12-31" ';
} else {
var where = 'where fk_expense IS NULL';
}
var query = 'select * from accounting ' + where + ' order by description';
Accounting.query(query, function (err, trans) {
this.transactions = trans;
});
var total = 0;
_.each(this.transactions, function (element, index, list) {
// format dates
element.datePosted = dateFormat(element.datePosted, 'dd/mm/yyyy');
var tmp0 = element.amount
var tmp1 = tmp0.replace(/ /g, '');
var tmp2 = parseFloat(tmp1);
total += tmp2;
});
this.total = total.toFixed(2);
return res.view();
}
This is the only way I am able to accomplish what Im trying to do but there are problems which I believe are caused by me putting the query objects in the "this" scope. The first problem is the page will crash after server restart on first reload. The second problem is everything seems to happen one step behind. What I mean is if I issue commands on the UI (eg submit a form) nothing will happen unless I take the same action twice.
So how do I pass multiple sets of data to my views without scoping them in "this"?
res.view({
corndogs: [{name: 'Hank the Corndog'}, {name: 'Lenny the Corndog'}]
});
Here is the relevant docs page: http://sailsjs.org/#!documentation/views
Also, it looks like you're not taking full advantage of Waterline for making SQL queries.

Resources