Google Scripts to Telegram - if statement issues when comparing strings - if-statement

function sendText(id,text) {
if(text == "hiii"){
var url = telegramUrl + "/sendMessage?chat_id=" + id + "&text=" + "sup?";
} else{
var url = telegramUrl + "/sendMessage?chat_id=" + id + "&text=" + "yo yo yo";
var response = UrlFetchApp.fetch(url);
Logger.log(response.getContentText());
}
}
My issue is that in Google Scripts (back end to Google Sheets), I have this function that reads in a message from telegram and, if the message reads "hiii" it should respond "sup?". Currently my code does not do this and instead executes only the else statement.

Related

Tracking user id from cookie with Google tag manager

I am trying to write my user ID to cookie. I can catch it from dataLayer variable from server when user is login in but user can be already logged in next session. So I tried to create custom JavaScript code that suppose to check if variable is not undefined and write a cookie and if the cookie exist then returns cookie value.
function() {
if ({{UID dataLayer}}) {
var d = new Date();
d.setTime(d.getTime() + 1000 * 60 * 60 * 24 * 365 * 2);
var expiresdate = 'Expires=' + d.toGMTString();
document.cookie = 'UIDcookie=' + {{UID dataLayer}} + '; ' + expiresdate + '; Path=/';
return {{UID dataLayer}};
} else if ({{UID Cookie}}) {
return {{UID Cookie}};
}
return;
}
But it works only when I'm in tagmanager debug mode, when it's off nothing suppose to happen. So my question is what am I doing wrong?
It's probably a question of timing. Try to fire the tag to the page load, in this way the function in JS variable should be able to read the cookie.

Dot net web service hosted in SharePoint server IIS connects to SharePoint online needs Web service restarts everyday

I have developed a web service using C# dot net coding which will connect to SharePoint online - and that web service I have hosted in one of the SharePoint on-premise IIS front end server - but I see some strange behavior. If we call that web service first time in a day using nintex workflow we get the below error:
**The GetListAttachmentsAndCopyToSPOnline workflow has ended unexpectedly for (no title).
For more information, please read this article: http://go.microsoft.com/fwlink/?LinkID=323543&clcid=0x409
Click here to view the workflow status.**
But once we restart the particular web service from IIS - everything start working perfectly. I mean in order to work with that web service every day at least once we need to restart the web service from the IIS....Not getting any clue why is this behavior? Any help would be much appreciated.
Sample web service code:
using (ClientContext ctx = new ClientContext(siteURL))
{
bool isSONumberFound = false;
string userName = "MyUserName";
string passWord = "MyPassword";
if (salesOrderNumber.Length <= 7)
{
salesOrderNumber = "000" + salesOrderNumber;
}
using (SecureString securedPassWord = new SecureString())
{
foreach (char c in passWord.ToCharArray()) securedPassWord.AppendChar(c);
ctx.Credentials = new SharePointOnlineCredentials(userName, securedPassWord);
Web web = ctx.Web;
try
{
ctx.Load(web);
ctx.ExecuteQuery();
List list = web.Lists.GetByTitle(documentLibrayName);
var camelQuery = new CamlQuery() { ViewXml = "<View><Query><Where><Eq><FieldRef Name='OrderID' /><Value Type='Text'>" + salesOrderNumber + "</Value></Where></Query></View>" };
var queryResults = list.GetItems(camelQuery);
ctx.Load(queryResults);
ctx.ExecuteQuery();
int countSalesOrder = queryResults.Count;
if (countSalesOrder >= 1)
{
isSONumberFound = true;
using (StreamWriter w = System.IO.File.AppendText(logFileName))
{
string logMessageSONotFound = "Sales Order Number: " + salesOrderNumber + "is found in the target document library: " + documentLibrayName + "of" + siteURL + ", so please enter the valid SO number";
Log(logMessageSONotFound, w);
w.Flush();
w.Close();
w.Close();
}
}
else
{
isSONumberFound = false;
using (StreamWriter w = System.IO.File.AppendText(logFileName))
{
string logMessageSONotFound = "Sales Order Number: " + salesOrderNumber + "is not found in the target document library: " + documentLibrayName + "of"+ siteURL+", so please enter the valid SO number";
Log(logMessageSONotFound, w);
w.Flush();
w.Close();
w.Close();
}
}
}
catch (Exception ex)
{
using (StreamWriter w = System.IO.File.AppendText(logFileName))
{
Log(ex.Message.ToString(), w);
}
}
}
return isSONumberFound;
}
}
}
}

How do I output information in pre-request script

Using the standalone version of Postman, how do I output some debug information in Postman pre-request script?
The code below works great for tests (post-request) but not for pre-request since there is no tests[] array.
var jsonData = JSON.parse(responseBody);
tests["key = " + jsonData.key] = true; // debug message
tests["value = " + jsonData.value] = true; // debug message
The only way I could find to accomplish this is by using:
console.log("key = " + key);
console.log("value = " + value);
And then open up the Postman console (Cmd + Option + C / Ctrl + Alt + C) to view the debugs logs in a different window.

UploadFile doesn´t work

Hi we are using "dropnet" API and works fine until today, just is not working the UploadFile method, play media, move or delete works fine, but the upload is not working can someone help to figuredout why?
basically the process upload the file and returns no error, but the file (.mp3 files) is not uploaded into my dropbox account as had been doing until last Friday. We tried to move or delete a file, also play the mp3 from my web page and it works perfect! How can we try to catch the error?
we use this code:
var fecha = DateTime.Now.ToString("dd-MM-yyyy");
DropNet.Models.MetaData uploaded = new DropNet.Models.MetaData();
uploaded = _client.UploadFile("/CRM_Proximitas/" + portal + "/" + Request.QueryString["idReclamo"].ToString() + "/" + fecha, hidTipo.Value.ToString() + hidID.Value.ToString() + "_" + fecha + "_" + usuario + "." + uplArchivo.FileName.ToLower().Split('.')[1], uplArchivo.FileBytes);
if (uploaded != null)
{
if (hidTipo.Value.ToString() == "R")
{
objCommand.CommandText = "INSERT INTO ReclamoAudio (idReclamo,path,Autor,Fecha) VALUES (" + Request.QueryString["idReclamo"].ToString() + ",'" + uploaded.Path.ToString() + "'," + Session["UserID"].ToString() + ",getdate())";
}
else if (hidTipo.Value.ToString() == "T")
{
objCommand.CommandText = "INSERT INTO ReclamoAudio (idReclamo,idTransaccion,path,Autor,Fecha) VALUES (" + Request.QueryString["idReclamo"].ToString() + "," + hidID.Value.ToString() + ",'" + uploaded.Path.ToString() + "'," + Session["UserID"].ToString() + ",getdate())";
}
objCommand.CommandType = CommandType.Text;
objCon.Open();
drContacto = objCommand.ExecuteReader();
objCon.Close();
string codigo = "window.opener.location.reload();self.close();";
Page.ClientScript.RegisterStartupScript(this.GetType(), "FinalizarCarga", codigo, true);
}
We have a website with IIS 7 + Framework 2.0, also the Dropbox App now is in Development Status, this can we cause an issue?
Please I need your help.
Thanks a lot!

how to start intro.js tour only on first visit to website

I have implemented intro.js to my website. But I wanted to start the tour only on first visit. may be by using cookies.. website is made with html no php..
JavaScript cookies are a solution although I should point out that it will only work for as long as the user keeps the cookie.
//set the cookie when they first hit the site
function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}
//check for the cookie when user first arrives, if cookie doesn't exist call the intro.
function getCookie(c_name)
{
var c_value = document.cookie;
var c_start = c_value.indexOf(" " + c_name + "=");
if (c_start == -1)
{
c_start = c_value.indexOf(c_name + "=");
}
if (c_start == -1)
{
c_value = null;
}
else
{
c_start = c_value.indexOf("=", c_start) + 1;
var c_end = c_value.indexOf(";", c_start);
if (c_end == -1)
{
c_end = c_value.length;
}
c_value = unescape(c_value.substring(c_start,c_end));
}
return c_value;
}
code is from http://www.w3schools.com/js/js_cookies.asp
obviously there's some blanks you'll have to fill in there, but it's a good starting point for working with cookies in javascript.
EDIT:
So you want to make a new function, put it in the head, inside script tags (if you have them already, just copy the function into there (you'll want to put the other two functions I provided within the script tag also)). This function will check to see if you have a cookie. If you do, just return. If you don't, create the cookie and run the intro,
<head>
<script type="text/javascript">
function checkCookieIntro(){
var cookie=getCookie("mySite");
if (cookie==null || cookie=="") {
setCookie("mySite", "1",90);
runIntro(); //change this to whatever function you need to call to run the intro
}
}
</script>
</head>
now change your body to be:
<body onload="checkCookieIntro()">
so when the body loads it will check to see if a cookie exists, if it doesn't, create a cookie with a value of one that will last for 90 days (unless the user deletes it) and then run the intro. If the cookie does exist with a value then it does nothing.