scriptlab for outlook - error with function getattachmentsasync - api

I am a newbie to 'script lab' for outlook. I need to access attachments (open & save, but this question is not that far). I use function "getattachmentsasync", code below, but it raised an error:
["Uncaught TypeError: Office.context.mailbox.item.getAttachmentsAsync is not a function", "https://script-lab-runner.azureedge.net/", 14, 33, TypeError]
code:
$("#run").click(run);
function run() {
Office.context.mailbox.item.getAttachmentsAsync(function (att) {
console.log(att)
} );
}

Related

How to write custom errors and return messages with error keyword Solidity

I tried to make a custom error but it doesn't return a message to revert
How could I make it return a message?
/// custom error
error MyCustomError(address _address);
if user { revert MyCustomError({address: msg.sender}) }
I got this error
Runtime error: revert
There are two errors:
1- if statement should be inside a function
2- when you defined the custom error,you defined the named parameter as _address
contract Test {
address public user;
/// custom error
error MyCustomError(address _address);
function revertError() public view {
// I just had to pass a valid condition. address(0)=0x0000000000000000000000000000000000000000
// if(user) would give this error: "Type address is not implicitly convertible to expected type bool"
if(user!=address(0))
{
revert MyCustomError({_address: msg.sender});
}
}
}

Typescript unsafe member access error in Vue when referring to property using "this."

I get the above error when I refer to a property in the method section using "this."
I had previously posted a more specific version of this error.
"Unsafe member access on an any value" TypeScript error
I thought I would repost since I am getting this error for all properties that I have defined.
=== This is my vue file =====
<script lang="ts">
export default {
name: 'Componentname',
data () {
return{
message: 'initial value',
}
}
methods: {
samplefunction () {
this.message = 'hello world'
}
}
====================
When I run this, or some reason typescript is not able to detect that message is a string and gives me the following error at the highlighted line
#typescript-eslint/no-unsafe-member-access: Unsafe member access
.message on an any value.
So my understanding is that TypeScript understand that from "message: 'initial value' " that it message is of string type. In fact when I hover my mouse over it, it does show that its identified as a string type. No matter what I do if I use this.message in any of the methods, the error occurs. In fact for all the properties that I defined, I get the error when I use "this.propertyname" The astonishing thing is that the code works perfectly fine and I don't see any errors or warning in the console.
Sorry if this is too late.
Aren't you missing the typing?
data(): { message: string } {
return {
message: 'initial value',
};
},
The same goes for the method.
samplefunction(): void {
this.message = 'hello world'
}

#objc func expression resolves to an unused function

I'm new to swift and trying to call a method when the user presses some hotkey shortcut.
I have the following code: https://pastebin.com/pF8wk7jL
I'm trying to run togglePopover on this handler: hotKey.keyDownHandler.
This:
hotKey.keyDownHandler = {
self.togglePopover(_:)
}
returns the error "Expression resolves to an unused function"
and this:
hotKey.keyDownHandler = {
let call = self.togglePopover(_:)
call(_:)
}
returns the error "Cannot find call in scope".
Cannot fix the issue, can someone help?
If I do:
hotKey.keyDownHandler = {
print("teste")
}
works good!

How do I get the Event.Complete event in a file upload to fire in Flash Builder

The file is getting uploaded properly and my ProgessEvent.Progress method is showing 100% complete, but my Event.Complete method does not fire. Do I have to send something specific back from the server? I am simply sending back a success message. I am not getting any errors.
I suppose I could just proceed when the progress method hits 100%. Shouldn't the Event.Complete method be firing after the data is sent and a response is received from the server?
**Update: I am getting an error with my Event.Complete method....
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event#1277971f1 to flash.events.DataEvent.
* I fixed the problem by changing my onLoadComplete(event:DataEvent) method to onLoadComplete(event:Event). The error went away and I my method is now firing. I will answer my own question when the system allows me to.
Relative code follows:
fileRef = new FileReference();
fileRef.addEventListener(Event.SELECT, onFileSelected);
fileRef.addEventListener(Event.COMPLETE, onUploadComplete);
fileRef.addEventListener(ProgressEvent.PROGRESS,onUploadProgress);
fileRef.addEventListener(IOErrorEvent.IO_ERROR, onUploadError);
fileRef.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onUploadError);
private function onUploadProgress(event:ProgressEvent):void {
status = ((event.bytesLoaded * 100) / event.bytesTotal).toString();
}
private function onUploadComplete(event:DataEvent): void {
status = "Complete";
}
private function onUploadError(event:Event):void {
if (event is IOErrorEvent) {
Alert.show((event as IOErrorEvent).text.toString());
} else if (event is SecurityErrorEvent) {
Alert.show((event as SecurityErrorEvent).text.toString());
} else {
status = "Unknown error";
}
}
I changed ...
private function onUploadComplete(event:DataEvent):void {
status = "Complete: "+event.toString();
}
To...
private function onUploadComplete(event:Event):void {
status = "Complete: "+event.toString();
}
I am guessing this is because I am not sending data back, only a simple xml block. Hope this helps someone else.

Simple-LInked Error

I have placed the simple linkedin class on my server and added my api keys etc, however when i call the demo page i get the following error:
Parse error: syntax error, unexpected T_FUNCTION in /home/mycv/public_html/dev/linkedin_3.2.0.class.php on line 259
this is the code for the area around line: 259
if(is_array($http_code_required)) {
array_walk($http_code_required, function($value, $key) {
if(!is_int($value)) {
throw new LinkedInException('LinkedIn->checkResponse(): $http_code_required must be an integer or an array of integer values');
}
line 259: seems to refer to the second line starting with array walk.
Thanks
Anonymous functions only became available in PHP 5.3.0. Line 259 above uses an anonymous function, so that would explain the error if your version pre-dates support.
Just make the anonymous function as a named function and call it in the checkResponse function:
function **innerfunction**($value, $key) {
if(!is_int($value)) {
throw new LinkedInException('LinkedIn->checkResponse(): $http_code_required must be an integer or an array of integer values');
}
}
private function checkResponse($http_code_required, $response) {
// check passed data
if(is_array($http_code_required)) {
array_walk($http_code_required, **innerfunction**($value, $key));
}
}