I already read the documentation in
http://docs.telerik.com/kendo-ui/api/javascript/ui/spreadsheet#methods-insertSheet
But on that link I didn't see the example for using this function.
Can someone give me the example for insertSheet method and removeSheet method?
Thanks.
//insertSheet:
var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
spreadsheet.insertSheet({name:'TEST'}); //you can set more than "name"
//removeSheet:
var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
var sheetWillBeDeleted = spreadsheet.sheetByName("TEST"); //you can also use sheetByIndex function to get the sheet by index.
spreadsheet.removeSheet(sheetWillBeDeleted);
Related
I'm currently trying to get a CCD from Cerner's CODE using the FHIR DocumentReference resource. In order to get a CCD the $docref operation has to be passed in the URL (example below) but the FHIR library we are using doesn't allow to use this operation.
http://fhir.cerner.com/millennium/dstu2/infrastructure/document-reference/#operation-docref
Any ideas? Anyone has been able to do this in C#?
You can use the official FHIR library for .Net, see https://github.com/FirelyTeam/fhir-net-api for the source, or add the Hl7.Fhir.Dstu2 library it to your project through NuGet.
This library has a FhirClient, that you can point to your endpoint and use to call the operation.
Here's how that could be achieved - values taken from the documentation you linked to:
var c = new FhirClient("https://fhir-open.cerner.com/dstu2/ec2458f2-1e24-41c8-b71b-0e701af7583d/");
var p = new Parameters();
p.Parameter.Add(new Parameters.ParameterComponent() { Name = "patient", Value = new FhirString("12724066") });
p.Parameter.Add(new Parameters.ParameterComponent() { Name = "type", Value = new CodeableConcept("http://loinc.org", "34133-9") });
var result = c.TypeOperation<DocumentReference>("docref", p, useGet: true);
I have a lot of picture links in my Google Sheet:
https://drive.google.com/file/d/1BDj24_6uz-ZQlGWLy0o1_DES6tJI3NMu/view?usp=sharing
I want to get the filename behind the link. When i open the link and save the image the image filename is: "FILENAME.jpg" or something similar
I want to get this information in Sheets.
How can i do that?
An Apps Script Solution
Thanks to #Tanaike for obtaining clarifications in the comments.
First enter your links in the format shown below in a Google Sheet.
The name of the titles is not important, but this particular script starts getting names from the 2nd row.
If you don't know how to create a script, there are tutorials here offered by Google. You should create the script from the same Sheet. That is, from the menu in the Sheet:
In the script editor, copy and paste the following code:
function getNames() {
var activeRange = SpreadsheetApp.getActiveSheet().getDataRange();
var height = activeRange.getHeight();
var links = SpreadsheetApp.getActiveSheet()
.getRange("A2:A" + height)
.getValues();
var nameValues = [];
links.forEach((row) => {
try {
var link = row[0];
var fileID = getIdFromLink(link);
var name = DriveApp.getFileById(fileID).getName();
nameValues.push([name]);
} catch (e) {
nameValues.push(["NO NAME FOUND"]);
}
});
var nameRange = SpreadsheetApp.getActiveSheet().getRange("B2:B" + height);
nameRange.setValues(nameValues);
}
function getIdFromLink(link) {
var regex = new RegExp(
/(?<=https:\/\/drive\.google\.com\/file\/d\/)(.+)(?=\/)/
);
return regex.exec(link)[0];
}
Run the getNames function. The first time it will ask you to grant some permissions, grant them. Then it should fill in the files names.
References
Apps Script Overview
Spreadsheet service in Apps Script
Drive service in Apps Script
How can I run a Glide query from in a widget? (Service Portal)
This code runs fine in the script-background editor, but it doesn't work in the Server-script section of my widget:
var grTask = new GlideRecord('task');
grTask.get('number', "REQ0323232"); // hardcoded good sample
destination_sys_id = grTask.sys_id;
When I run the code in Scripts, I get:
*** Script: sys_id: 0f4d[...]905
When I run it in the widget, I get:{}
To elaborate on my Widget code:
Body HTML template
data.destination_sys_id = {{data.destination_sys_id }}
Server script
(function(){
var destination_sys_id = "initialized";
var grTask = new GlideRecord('task');
grTask.get('number', "REQ0323232");
destination_sys_id = grTask.sys_id;
data.destination_sys_id = destination_sys_id;
})()
you can add it as c.data.destination_sys_id nad at the time of assigning the value to object always use .toString() in order to stringify the field value.
I needed a .toString(); in my server script:
(function(){
var destination_sys_id = "initialized";
var grTask = new GlideRecord('task');
grTask.get('number', "REQ0323232");
destination_sys_id = grTask.sys_id.toString(); // <- note the addition of .toString()
data.destination_sys_id = destination_sys_id;
})()
Another way is to use grTask.getUniqueValue() instead of grTask.sys_id.toString().
Also, getters and setters are recommended with GlideRecord, so use grTask.getValue('sys_id') instead of grTask.sys_id.toString().
I have a spreadsheet that contains links created after a form entry. I'd like to call the external API of a link shortening service (not google's link shorten-er) to take the link created in a given cell, shorten it, return the value and have Google Apps Script insert that shortened link into a new cell.
Is this possible? Specifically, can I use jQuery's AJAX methods? Where should I start.
By checking the internet, I found this stackExchange question, you can try to follow the solution in this post. What you need here is URL shortener API under the resources in the script editor (Tools > Script editor) select the Advanced Google Services and activate the UrlShortener.
Here is the sample code that you need to use.
function onOpen() {
SpreadsheetApp.getUi()
.createMenu("Shorten")
.addItem("Go !!","rangeShort")
.addToUi()
}
function rangeShort() {
var range = SpreadsheetApp.getActiveRange(), data = range.getValues();
var output = [];
for(var i = 0, iLen = data.length; i < iLen; i++) {
var url = UrlShortener.Url.insert({longUrl: data[i][0]});
output.push([url.id]);
}
range.offset(0,1).setValues(output);
}
For more information, explanation and some sample pictures, just check the link above.
The code included in this post is using an installable "On Edit" trigger in an addon. An error message is coming up in the console when I pass the id of the document as argument to .forSpreadsheet(ssss) in Google Apps Script:
This Add-on is attempting to create a trigger on a document that it is not currently being used in.
It seems like the Add-on doesn't recognize the active sheet properly. Where should the functions be placed? onInstall(), onOpen()?
function createSpreadsheetEditTrigger() {
var ssss = SpreadsheetApp.getActive().getId();
ScriptApp.newTrigger('onEditTrigger')
.forSpreadsheet(ssss)
.onEdit()
.create();
}
function onEditTrigger(e){
isSheetName('SheetName') && sendingEmailFunction(e);
}
Don't use the ID.
Currently:
var ssss = SpreadsheetApp.getActive().getId();
Should be:
var ssss = SpreadsheetApp.getActive();
The parameter ss for .forSpreadsheet(ss) must be a spreadsheet object. You are entering a string. getId() returns a string. Always look at the data types returned, and the data type required.
Google Documentation
From https://developers.google.com/apps-script/guides/triggers/installable#managing_triggers_programmatically
function createSpreadsheetEditTrigger() {
var ss = SpreadsheetApp.getActive();
ScriptApp.newTrigger('myFunction')
.forSpreadsheet(ss)
.onOpen()
.create();
}