Server: Difference between revisions
From MobileX for SageCRM
Crmtogether (talk | contribs) (Created page with "The server plugin is stored in "js\\plugins\\PLUGINNAME\\server\\FILENAME.js if (params.EntityId) { var sql = "select pers_emailaddress...") |
Crmtogether (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
The server plugin is stored in "js\\plugins\\PLUGINNAME\\server\\ | The server plugin is stored in "js\\plugins\\PLUGINNAME\\server\\sendOrder.js | ||
In the Client documentation page FILENAME=sendOrder | |||
EG | |||
"js\\plugins\\PLUGINNAME\\server\\sendOrder.js" | |||
The code in the FILENAME is javscript and is executed. | |||
EG | |||
if (params.EntityId) { | |||
var sql = | var sql = | ||
"select pers_emailaddress \ | "select pers_emailaddress \ | ||
from vsummaryperson \ | from vsummaryperson \ | ||
where pers_personid={0}"; | where pers_personid={0}"; | ||
sql = clr.System.String.Format(sql, params.EntityId); | sql = clr.System.String.Format(sql, params.EntityId); | ||
var jsonResult = SQLJSONSerializer.ExecuteQueryToJSON(sql, false); | var jsonResult = SQLJSONSerializer.ExecuteQueryToJSON(sql, false); | ||
var jsonObject = eval(jsonResult); | var jsonObject = eval(jsonResult); | ||
//jsonObject runs the query and returns data | |||
// | //to access this data you can reference "jsonObject[0].pers_emailaddress" | ||
//GetFileContents - reads the file into a string | |||
var emailBody = email.GetFileContents("C:\\Program Files (x86)\\Sage\\CRM\\ | var emailBody = email.GetFileContents("C:\\Program Files (x86)\\Sage\\CRM\\CRM\\WWWRoot\\CustomPages\\SageCRMWS\\js\\plugins\\PLUGINNAME\\server\\email.txt"); | ||
//create an email object | |||
var emailSettings = { | var emailSettings = { | ||
to: jsonObject[0].pers_emailaddress, | to: jsonObject[0].pers_emailaddress, | ||
From: "uname@server.com", | From: "uname@server.com", | ||
subject: " | subject: "New Order", | ||
body: emailBody, | body: emailBody, | ||
host: "smtp.server.com", | host: "smtp.server.com", | ||
Line 33: | Line 34: | ||
pEnableSsl: true | pEnableSsl: true | ||
} | } | ||
//sendEmail - sends an email based on the settings | |||
// | |||
email.SendEmail(emailSettings.to, emailSettings.From, emailSettings.subject, emailSettings.body, emailSettings.host, emailSettings.port, emailSettings.UserName, emailSettings.Password, emailSettings.pIsBodyHtml, emailSettings.pEnableSsl); | email.SendEmail(emailSettings.to, emailSettings.From, emailSettings.subject, emailSettings.body, emailSettings.host, emailSettings.port, emailSettings.UserName, emailSettings.Password, emailSettings.pIsBodyHtml, emailSettings.pEnableSsl); | ||
//this is displayed on screen by the Factory.msgbox method | |||
//this is displayed on screen | Response.Write('Email sent to: '+jsonObject[0].pers_emailaddress); | ||
Response.Write('Email sent'); | } | ||
} |
Revision as of 13:06, 28 June 2016
The server plugin is stored in "js\\plugins\\PLUGINNAME\\server\\sendOrder.js
In the Client documentation page FILENAME=sendOrder
EG "js\\plugins\\PLUGINNAME\\server\\sendOrder.js"
The code in the FILENAME is javscript and is executed.
EG if (params.EntityId) { var sql = "select pers_emailaddress \ from vsummaryperson \ where pers_personid={0}"; sql = clr.System.String.Format(sql, params.EntityId); var jsonResult = SQLJSONSerializer.ExecuteQueryToJSON(sql, false); var jsonObject = eval(jsonResult); //jsonObject runs the query and returns data //to access this data you can reference "jsonObject[0].pers_emailaddress" //GetFileContents - reads the file into a string var emailBody = email.GetFileContents("C:\\Program Files (x86)\\Sage\\CRM\\CRM\\WWWRoot\\CustomPages\\SageCRMWS\\js\\plugins\\PLUGINNAME\\server\\email.txt"); //create an email object var emailSettings = { to: jsonObject[0].pers_emailaddress, From: "uname@server.com", subject: "New Order", body: emailBody, host: "smtp.server.com", port: "123", UserName: "uname@server.com", Password: "password", pIsBodyHtml: true, pEnableSsl: true } //sendEmail - sends an email based on the settings email.SendEmail(emailSettings.to, emailSettings.From, emailSettings.subject, emailSettings.body, emailSettings.host, emailSettings.port, emailSettings.UserName, emailSettings.Password, emailSettings.pIsBodyHtml, emailSettings.pEnableSsl); //this is displayed on screen by the Factory.msgbox method Response.Write('Email sent to: '+jsonObject[0].pers_emailaddress); }