Using bootstrap i make a data table which is working fine in localhost. But when i add that code snippet to my portlet in NetSuite dashboard table is showing but pagination and search box is not showing.[Data Table in Netsuite Dashboard][1]
'''
define(['N/file'],
function (file) {
function render(params) {
params.portlet.title = 'Services';
var myvar = '<!DOCTYPE html>' +
'<html lang="en">' +
'' +
'<head>' +
' <title>Bootstrap Example</title>' +
' <meta charset="utf-8">' +
' <meta name="viewport" content="width=device-width, initial-scale=1">' +
' <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">' +
' <link rel="stylesheet" href="https://cdn.datatables.net/1.10.24/css/dataTables.bootstrap4.min.css">' +
'</head>' +
'<style type="text/css">' +
' div.dataTables_wrapper {' +
' margin-bottom: 3em;' +
' }' +
'</style>' +
'<body>' +
' <div class="container-fluid">' +
' <table id="" class="table table-striped table-bordered display" style="width:100%">' +
' <thead>' +
' <tr>' +
' <th>Name</th>' +
' <th>Position</th>' +
' <th>Office</th>' +
' <th>Age</th>' +
' <th>Start date</th>' +
' <th>Salary</th>' +
' </tr>' +
' </thead>' +
' <tbody>' +
' <tr>' +
' <td>Tiger Nixon</td>' +
' <td>System Architect</td>' +
' <td>Edinburgh</td>' +
' <td>61</td>' +
' <td>2011/04/25</td>' +
' <td>$320,800</td>' +
' </tr>' +
' <tr>' +
' <td>Garrett Winters</td>' +
' <td>Accountant</td>' +
' <td>Tokyo</td>' +
' <td>63</td>' +
' <td>2011/07/25</td>' +
' <td>$170,750</td>' +
' </tr>' +
' <tr>' +
' <td>Michael Bruce</td>' +
' <td>Javascript Developer</td>' +
' <td>Singapore</td>' +
' <td>29</td>' +
' <td>2011/06/27</td>' +
' <td>$183,000</td>' +
' </tr>' +
' <tr>' +
' <td>Donna Snider</td>' +
' <td>Customer Support</td>' +
' <td>New York</td>' +
' <td>27</td>' +
' <td>2011/01/25</td>' +
' <td>$112,000</td>' +
' </tr>' +
' </tbody>' +
' </table>' +
' </div>' +
' <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>' +
' <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>' +
' <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>' +
' <script src="https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js"></script>' +
' <script src="https://cdn.datatables.net/1.10.24/js/dataTables.bootstrap4.min.js"></script>' +
' <script type="text/javascript">' +
' $(document).ready(function() {' +
' $(\'table.display\').DataTable();' +
' });' +
' </script>' +
'</body>' +
'' +
'</html>';
var content = '<td><span><b>Hello!!!</b></span></td>';
params.portlet.html = myvar;
}
return {
render: render
};
});
'''
[In Local Data Table][2]
[1]: https://i.stack.imgur.com/rfG1x.png
[2]: https://i.stack.imgur.com/4A2pt.png
Related
I'm trying to use the EWS DeleteItem operation, and here's how I'm calling it:
var mailbox = Office.context.mailbox;
var item = Office.cast.item.toItemRead(mailbox.item);
var requestResponse = mailbox.makeEwsRequestAsync(getDeleteItemRequest(item.itemId), callback2);
Here is my getDeleteItemRequest function:
function getDeleteItemRequest(id) {
var result = '<?xml version="1.0" encoding="utf-8"?> ' +
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types"> ' +
'<soap:Body> ' +
'<DeleteItem DeleteType="HardDelete" xmlns="https://schemas.microsoft.com/exchange/services/2006/messages"> ' +
'<ItemIds> ' +
'<t:ItemId Id="' + id + '" /> ' +
'</ItemIds> ' +
'</DeleteItem> ' +
'</soap:Body> ' +
'</soap:Envelope>';
return result;
}
But, I always get back ErrorInvalidRequest and the item is never deleted.
It is Exchange 2013 that I'm using. Why is this failing to delete the item?
Thanks!
DeleteItem isn't allowed in an Addin, only a subset of EWS Request are they are listed in https://learn.microsoft.com/en-us/office/dev/add-ins/outlook/web-services. You can use MoveItem or set a specific retention tag on the Item as an alternative.
In you request the XML schema definitions are wrong Microsoft did a mass update on the documentation and broke most EWS request (the changed http to https in the schema declaration which the server won't accept) so your request
function getMoveItemRequest(id, changeKey) {
var result =
'<?xml version="1.0" encoding="utf-8"?> ' +
'<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/" ' +
'xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> ' +
'<soap:Header> ' +
'<t:RequestServerVersion Version="Exchange2013" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" soap:mustUnderstand="0" /> ' +
'</soap:Header> ' +
'<soap:Body> ' +
'<MoveItem xmlns="https://schemas.microsoft.com/exchange/services/2006/messages" ' +
'xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types"> ' +
'<ToFolderId> ' +
'<t:DistinguishedFolderId Id="deleteditems"/> ' +
'</ToFolderId> ' +
'<ItemIds> ' +
'<t:ItemId Id="' + id + '" ChangeKey="' + changeKey + '"/> ' +
'</ItemIds> ' +
'</MoveItem> ' +
'</soap:Body> ' +
'</soap:Envelope> ';
return result;
}
should be
function getMoveItemRequest(id, changeKey) {
var result =
'<?xml version="1.0" encoding="utf-8"?> ' +
'<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/" ' +
'xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> ' +
'<soap:Header> ' +
'<t:RequestServerVersion Version="Exchange2013" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" soap:mustUnderstand="0" /> ' +
'</soap:Header> ' +
'<soap:Body> ' +
'<MoveItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" ' +
'xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> ' +
'<ToFolderId> ' +
'<t:DistinguishedFolderId Id="deleteditems"/> ' +
'</ToFolderId> ' +
'<ItemIds> ' +
'<t:ItemId Id="' + id + '" ChangeKey="' + changeKey + '"/> ' +
'</ItemIds> ' +
'</MoveItem> ' +
'</soap:Body> ' +
'</soap:Envelope> ';
return result;
}
I'm trying to delete an item using the EWS MoveItem XML request. I'm sending this request to the makeEwsRequestAsync function:
function getMoveItemRequest(id, changeKey) {
var result =
'<?xml version="1.0" encoding="utf-8"?>' +
'<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/" xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types">' +
'<soap:Header>' +
'<RequestServerVersion Version="Exchange2013" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" soap:mustUnderstand="0" />' +
'</soap:Header>' +
'<soap:Body>' +
'<MoveItem xmlns="https://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types">' +
'<ToFolderId>' +
'<t:DistinguishedFolderId Id="deleteditems" />' +
'</ToFolderId>' +
'<ItemIds>' +
'<t:ItemId Id="' + id + '" ChangeKey="' + changeKey + '" />' +
'</ItemIds>' +
'</MoveItem>' +
'</soap:Body>' +
'</soap:Envelope>';
return result;
}
I'm getting the item id from the message like this:
Office.context.mailbox.item.itemId
I'm getting changekey like this:
var mailbox = Office.context.mailbox;
var soapToGetItemData = getItemDataRequest(mailbox.item.itemId);
Office.context.mailbox.makeEwsRequestAsync(soapToGetItemData, function(result) {
var response = $.parseXML(result.value);
var responseString = result.value;
// TODO: May want to reconsider the logic for getting the ChangeKey
var indexOfChangeKey = responseString.indexOf("ChangeKey=\"");
var substringAfterChangeKey = responseString.substring(indexOfChangeKey + 11);
var indexOfQuotes = substringAfterChangeKey.indexOf("\"");
var changeKey = substringAfterChangeKey.substring(0, indexOfQuotes);
Here is the getItemDataRequest function:
function getItemDataRequest(itemId) {
var soapToGetItemData = '<?xml version="1.0" encoding="utf-8"?>' +
'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
' xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"' +
' xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' +
' xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">' +
' <soap:Header>' +
' <RequestServerVersion Version="Exchange2013" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" soap:mustUnderstand="0" />' +
' </soap:Header>' +
' <soap:Body>' +
' <GetItem' +
' xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"' +
' xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">' +
' <ItemShape>' +
' <t:BaseShape>IdOnly</t:BaseShape>' +
' <t:AdditionalProperties>' +
' <t:FieldURI FieldURI="item:Attachments" /> ' +
' </t:AdditionalProperties> ' +
' </ItemShape>' +
' <ItemIds>' +
' <t:ItemId Id="' + itemId + '"/>' +
' </ItemIds>' +
' </GetItem>' +
' </soap:Body>' +
'</soap:Envelope>';
return soapToGetItemData;
}
Yet, I'm getting an invalid response from this (the XML that is returned has "<faultstring xml:lang="en-US">The request is invalid." in it.)
Any ideas what's going on?
Thanks!
Needed to use http instead of https in the request.
function getMoveItemRequest(id, changeKey) {
var result =
'<?xml version="1.0" encoding="utf-8"?> ' +
'<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/" ' +
'xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> ' +
'<soap:Header> ' +
'<t:RequestServerVersion Version="Exchange2013" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" soap:mustUnderstand="0" /> ' +
'</soap:Header> ' +
'<soap:Body> ' +
'<MoveItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" ' +
'xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> ' +
'<ToFolderId> ' +
'<t:DistinguishedFolderId Id="deleteditems"/> ' +
'</ToFolderId> ' +
'<ItemIds> ' +
'<t:ItemId Id="' + id + '" ChangeKey="' + changeKey + '"/> ' +
'</ItemIds> ' +
'</MoveItem> ' +
'</soap:Body> ' +
'</soap:Envelope> ';
return result;
}
I try to insert a dynamic h3 to a dynamic div, hovewer something is odd as it gets inserted outside the lblUser div. I would also like to be inserted after the "Role" h3.
Here is my code : function showUsers() {
lblUserList.innerHTML = "";
for ( var i = 0; i < ajUserDataFromServer.length; i++ ) {
var lblUser = document.createElement('div');
lblUser.innerHTML = '<div class="lblUser">' + '<img src="' + ajUserDataFromServer[i].image + '" alt="user" class="lblUserImage" data-userImage="' + ajUserDataFromServer[i].image + '">' + '<h3 class="lblUserId">' + 'Id:' + ' ' + ajUserDataFromServer[i].id + '</h3>' + '<h3 class="lblUserRole" data-userRole="' + ajUserDataFromServer[i].role + '">' + 'Role:' + ' ' + ajUserDataFromServer[i].role + '</h3>' + '<h3 class="lblUserName" data-userName="' + ajUserDataFromServer[i].name + '">' + 'Name:' + ' ' + ajUserDataFromServer[i].name + '<h3 class ="lblUserLastName" data-userLastName="' + ajUserDataFromServer[i].lastname + '">' + 'Lastname:' + ' ' + ajUserDataFromServer[i].lastname + '</h3>' + '<h3 class="lblUserPassword" data-userPassword="' + ajUserDataFromServer[i].password + '">' + 'Password:' + ' ' + ajUserDataFromServer[i].password + '</h3>' + '<button id="btnEditUserBody" class="btnShowPage btnEditUser" data-userId="' + ajUserDataFromServer[i].id + '" data-showThisPage="pageUpdateUser">' + 'EDIT USER' + '</button>' + '<button class="btnDeleteUser" data-userId="' + ajUserDataFromServer[i].id + '" >' + 'DELETE USER' + '</button>' + '<h3 class="lblErrorMessage" id="lblDeleteUserErrorMessage">' + '</h3>' + '</div>';
if ( ajUserDataFromServer[i].email ) {
var lblUserEmail = document.createElement('h3');
lblUserEmail.innerHTML = '<h3 class="lblUserEmail" data-userEmail="' + ajUserDataFromServer[i].email + '">' + 'Email:' + ' ' + ajUserDataFromServer[i].email + '</h3>';
lblUser.appendChild( lblUserEmail );
}
if ( ajUserDataFromServer[i].phonenumber ) {
var lblUserPhoneNumber = document.createElement('h3');
lblUserPhoneNumber.innerHTML = '<h3 class="lblUserPhoneNumber" data-userPhoneNumber="' + ajUserDataFromServer[i].phonenumber + '">' + 'Phone-number:' + ' ' + ajUserDataFromServer[i].phonenumber + '</h3>';
lblUser.appendChild( lblUserPhoneNumber );
}
lblUserList.appendChild( lblUser );
}
}
I can see a few things wrong with the code, for example:
var lblUserEmail = document.createElement('h3');
lblUserEmail.innerHTML = '<h3 class="lblUserEmail" data-userEmail="' + ajUserDataFromServer[i].email + '">' + 'Email:' + ' ' + ajUserDataFromServer[i].email + '</h3>';
Should be something like:
var lblUserEmail = document.createElement('h3');
lblUserEmail.classList.add("lblUserEmail");
lblUserEmail.setAttribute("data-userEmail", ajUserDataFromServer[i].email);
lblUserEmail.innerText = 'Email:' + ' ' + ajUserDataFromServer[i].email;
Now you can append it:
lblUser.appendChild(lblUserEmail);
If you do it your way you wil get nested h3 and div elements.
Furthermore, you need to close your img tag. I can advice creating those tags either in code or with the new es5 string interpolation this will clean up your code and will show you these types of errors.
I want to try and print ".00" after the variables cache.todayHigh and cache.todayLow are whole numbers.
if (ddimgtooltip.showTips) {
// update tooltip
tip = 'High ' + strings.baro_info + ': ' + cache.todayHigh + ' ' + data.pressunit + ' ' + strings.at + ' ' + data.TpressTH +
' <br> ' + strings.minimum_info + ' ' + strings.baro_info + ': ' + cache.todayLow + ' ' + data.pressunit + ' ' + strings.at + ' ' + data.TpressTL;
if (cache.trendVal !== -9999) {
tip += '<br>' + strings.baro_trend_info + ': ' + baroTrend(cache.trendVal, data.pressunit, true) + ' ' +
(cache.trendValRnd > 0 ? '' : '') + cache.trendValRnd + ' ' + data.pressunit + '/hr';
}
$('#imgtip5_txt').html(tip);
}
e.g. 1017 hPa to 1017.00 hPa.
Is this possible?
Thanks,
William
Try this,
var yvalue = '1702 hpa';
var num = yvalue.replace(/[^0-9]+/ig,"");
value = Number(num).toFixed(2);
var fvalue= value +' '+yvalue.split(' ')[1]
console.log(fvalue);
I'm using firebase to get this data,
I'd like to add href tags to message.userName output
$('#winners').text('Winner:' + ' ' + message.userName + ' ' + ' '+ 'score:' + ' ' + message.score + ' ' + ' '+ 'Start time:' + ' ' + message.startTime + ' ' + ' '+ 'End time:' + '' + message.endTime );
I've tried
$('#winners').text('Winner:' + ' ' + '<a href=\"scoreTracker.php?id='+message.userID +'\"> + ' message.userName + ' ' + ' '+ 'score:' + ' ' + message.score + ' ' + ' '+ 'Start time:'
+ ' ' + message.startTime + ' ' + ' '+ 'End time:' + '' + message.endTime + '<\a>' );
To avoid XSS attacks (among other weird problems), append an anchor element and set its text. This means you don't have to worry about escaping anything.
$('#winners').append([
'Winner: ',
$('<a>')
.attr('href', 'scoreTracker.php?id=' + encodeURIComponent(message.userId))
.text(
message.userName + ' score: ' + message.score + ' Start time: ' + message.startTime + ' End time: ' + message.endTime
)
]);
If your HTML gets much more complicated, might I suggest a JavaScript template engine? I use Swig for most projects, but there are many choices.
you have to use append() , or html()
$('#winners').append('Winner:' + ' ' + message.userName + ' ' + ' '+ 'score:' + ' ' + message.score + ' ' + ' '+ 'Start time:' + ' ' + message.startTime + ' ' + ' '+ 'End time:' + '' + message.endTime );
this may help you to understand better :
http://api.jquery.com/category/manipulation/dom-insertion-inside/
Both #Brad and #ProllyGeek are correct -- but #Brad's solution is best given the potential risk of XSS attacks. Here is his code, just cleaned up a bit for better readability. :)
$('#winners').append([
'Winner: ',
$('<a />')
.attr('href', 'scoreTracker.php?id=' + encodeURIComponent(message.userId)
.text(message.userName + ' score: ' + message.score + ' Start time: ' + message.startTime + ' End time: ' + message.endTime)
]);
Hope this helps!