Using document.saveAs(fileId) function - google-drive-realtime-api

Please share if anyone has a deep info of how to use this function and what fileId to input in realtime api document.saveAs(fileId) function.
i have provided the api documentation
https://developers.google.com/google-apps/realtime/reference/gapi.drive.realtime.Document.html#saveAs

I think the link you've provided says what it does already.
"Saves a copy of this document to a new file. After this function is
called, all changes to this document no longer affect the old document
and are instead saved to the new file. "
snippet:
var newDoc = gapi.drive.realtime.loadFromJson(jsonData);
newDoc.saveAs(fileId);
The fileId mentioned here is the id of the new document you wish your future changes to be copied to and reflect the incoming changes. Example:
If you don't have idea what fileId looks like, it's something like this.
If it's a docs file,
https://docs.google.com/document/d/1Fh6s7an-7I6VuDBxZMcxcaL9cG1XplryHPOGnznWlns/edit
1Fh6s7an-7I6VuDBxZMcxcaL9cG1XplryHPOGnznWlns is the fileId.
If it's a sheets file,
https://docs.google.com/spreadsheets/d/1BD97LZlG5qxVHyvPvZ-i_mahh-yUPuFCG2ZW4yhN8vs/edit#gid=0
1BD97LZlG5qxVHyvPvZ-i_mahh-yUPuFCG2ZW4yhN8vs is the fileId.

Related

Google sheets handling async loads

I have a google drive sheet that I am trying to load data. In selenium, I can go to the page and wait for a second then parse the page. Is there anyway to wait in a similar manner?
I am trying to get the data from this table :"https://www.cboe.com/delayed_quotes/vix/future_quotes/"
=IMPORTHTML("https://www.cboe.com/delayed_quotes/vix/future_quotes/","table",1)
returns
N/A
Imported content is empty.
importing JavaScript elements is not supported in google sheets:
I believe your goal is as follows.
You want to retrieve the table in the site of the URL https://www.cboe.com/delayed_quotes/vix/future_quotes/.
Issue and workaround:
When I saw the HTML data of the URL, it seems that your expected table is not included. But, I notice that the table is created by Javascript using the values retrieved from the API. So, in this answer, I would like to propose directly retrieving your expected values from the API. In this case, the retrieved value is JSON data. So, I would like to propose using a Google Apps Script as a custom function.
Sample script:
Please copy and paste the following script to the script editor of Spreadsheet, and save the script. When you use this script, please put a custom function of =SAMPLE() to a cell. By this, the values are returned.
function SAMPLE() {
const url = "https://www.cboe.com/us/futures/api/get_quotes_combined/?symbol=AMT1&rootsymbol=null";
const res = UrlFetchApp.fetch(url);
const obj = JSON.parse(res.getContentText());
const header = ["symbol", "expiration", "last_price", "change", "high", "low", "settlement", "volume"];
return obj.data.map(o => header.map(h => o[h]));
}
Testing:
When this script is tested, the following result is obtained.
Note:
This answer is the current answer. When the specification of the site and the API is changed, this script might not be able to be used. So, please be careful about this.
References:
Custom Functions in Google Sheets
fetch(url)

File upload and attach in Acumatica

I'm actually new in Acumatica Framework. I'm having some issues to understand how to attach the file. The problem is that in this answer Attach file to data row they talk about
PXNoteAttribute.SetFileNotes(Base.Caches[typeof(DAC)], dacRecord, file.UID.Value);
I do not understand what do they refer about "Base.Caches[typeof(DAC)], dacRecord", I've already saved the file but the step of setting the file is my problem...
You need to provide the Cache object corresponding to the type of your Record and the Record itself. For example if you need to attach file to SOOrder you will provide values like below:
var currentSOOrder = soOrderEntry.Document.Current;
PXNoteAttribute.SetFileNotes(soOrderEntry.Caches[typeof(SOOrder)], currentSOOrder , file.UID.Value);

How to add custom variable and its related value into protractor-html-screenshot-reporter metadata

There is a req of adding one header field and one corresponding value underneath it in the html report generated by using protractor-html-screenshot-reporter plugin.
I tried exploring it and found that the html page generated is already created into jsonparser.js file of this plugin and in-fact the data is also being added to this html table created.
I tried one solution like adding the below mentioned lines in conf file
metadataBuilder: function metaDataBuilder(spec, descriptions, results, capabilities) {
return {value: results.passed()};
}
but this does not work for me.
Please let me know if anyone has any idea..

Close method not working in Office

Im trying to use Microsoft.Office.Interop.Word._Document.Close() in a .net 3.5 windows form app.
No matter how much I search here and on Google I cannot find the correct parameters to put in the Close method.
I am using version 14.0.0.0 of Microsoft.Office.Interop.Word and I would like to close the document without saving and ideally ensure that the application can isolate the document thread so that users can still open word documents outside the running application.
See the Close method of the Document class described in MSDN. If you need to omit the parameter and use the default value - pass the Type.Missing parameter.
Try this:
object doNotSaveChanges = Word.WdSaveOptions.wdDoNotSaveChanges;
object missing = System.Reflection.Missing.Value;
_Document.Close(ref doNotSaveChanges, ref missing, ref missing);
This is the source
I'm not sure if you'll need the middle line or not. It's not from the original source it's from here

Modify Filename Before Saving in Django using model.FileField

I have a model.FileField(upload_to='%Y/%m/%d') field. This works great; however, I want to rename the file based on the context of the user uploading the file before it is saved. Is there a way of modifying the request object before it saved to accomplish this?
I have come across people with similar issues but the answers always point back to the Django documentation. I have tried figuring this out using the documentation but can't. Can someone provide some code to show hot to solve this?
Thanks in advance.
you can use function for upload_to value with instance and filename inputs and return path and file name
for example:
def upload_to_func(instance, filename):
now = datetime.now()
return os.path.join(str(now.year), str(now.month), str(now.day), filename)
field_x = model.FileField(upload_to=upload_to_func)
you can change path and filename in function

Resources