I've defined a property that is called Replyand the document type is RichTextEditor.
I cannot get the value of Reply. This problem is only for properties that type of it is RichTextEditor!!!
How can I get the value of Rich Text Editor in Umbraco backoffice?
I've used Umbraco 7.x and ASP.NET MVC.
angular.module("umbraco").controller("Reply.controller", function ($scope, $http, $routeParams) {
$scope.SendReply = function () {
var contentId = $routeParams.id;
var replyText = $("#Reply").val(); // without value ??? (type of Reply is RichTextEditor)
var email = $("#Email").val(); // It's OK.
var dataObj = {
ReplyText: replyText,
ContentId: contentId,
Email: email,
};
$http.post("backoffice/Reply/ReplyToIncomingCall/ReplyMessage", dataObj).then
(
function (response) {
alert("YES!");
//TODO:
}
);
}
});
For getting the value of Reply, you can use this code.
var replyList = $("[id*='Reply']");
for (i = 0; i < replyList.length; ++i) {
var rText = replyList[i].value;
if (!(rText === "" || rText === null)) {
replyText = rText;
}
}
Related
I want to have an automatic email machine, without having to write all of the messages and email addresses myself.
I'm really new to this, so please don't be too harsh.
function sendOrder() {
var ui = SpreadsheetApp.getUi();
var response = ui.alert('Are you sure you want to send the order?',
ui.ButtonSet.YES_NO);
var deliveryDate = ui.prompt('Delivery date:');
// Process the user's response.
if (response == ui.Button.YES) {
var s = SpreadsheetApp.getActive().getSheetById('1pON34oXVhlpC8goyBxfu6-Gw92tgQBUVUpskZUtgp4E');
var ss = SpreadsheetApp.getActiveSpreadsheet();
var range = ss.getActiveSheet().getDataRange();
var range = s.getRange('A1:C102');
var to = "example#example.com";
var body = '';
var htmlTable = SheetConverter.convertRange2html(range);
var body = "Here is the table:<br/><br/>" +
htmlTable +
"<br/><br/>The end."
MailApp.sendEmail(to, 'Subject', body, {
htmlBody: body
});
};
SpreadsheetApp.getUi().alert('Yeah! Your order has been sent :)');
}
I just expect this to give me a box to enter a date, once the date is entered it should say it has sent and our supplier will see all of the orders.
Issue:
This is because function getSheetById() does not exist.
Solution:
Use openById() instead:
var s = SpreadsheetApp.openById('yourIdHere');
Reference:
openById()
you need to add the function getSheetById(id):
function getSheetById(id) {
return SpreadsheetApp.getActive().getSheets().filter(
function(s) {return s.getSheetId() === id;}
)[0];
}
I have been trying to get the data from response and add it to controller, but no luck.
Here is my previous question.
How is it done in AngularJS?
The code that I used for this is like this:
invitePeersController.getGmailContacts = function(){
console.log("I come in gmail contacts");
var clientId = "contact key";
var apiKey = "apiKey";
var scopes = "https://www.googleapis.com/auth/contacts.readonly";
authorize();
function authorize() {
gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: false}, handleAuthorization);
}
function handleAuthorization(authorizationResult){
invitePeersController.gmailContacts = [];
var gmailData = [];
if (authorizationResult && !authorizationResult.error){
var urlContact = "https://www.google.com/m8/feeds/contacts/default/thin?alt=json&access_token=" + authorizationResult.access_token + "&max-results=50000&v=3.0";
var promiseGoogleData = HttpService.httpGetExternalLink(urlContact);
promiseGoogleData.then(function (response) {
var jsonChildData = response.data.feed.entry;
for(var i=0; i<jsonChildData.length ;i++){
var item = {};
try{
var name = jsonChildData[i].title.$t;
var email = jsonChildData[i].gd$email[0].address;
if(name.substring(1, name.length-1) && email.substring(1, email.length-1)){
item ["name"] = name.substring(1, name.length-1);
item ["email"] = email.substring(1, email.length-1);
item ["id"] = email.substring(1, email.length-1).replace(/[^a-zA-Z ]/g, "");
invitePeersController.gmailContacts.push(item);
gmailData.push(item);
}
}catch(error){
console.log("Error is thrown while trying to read gmail resposne");
}
}
$state.go("app.inviteContacts");
InvitePeersService.setGmailContactsData( invitePeersController.gmailContacts);
return response;
})
.catch(function (error) {
console.log("Something went terribly wrong while trying to get Gmail Data.");
});
}
}
}
Also don't forget to add the domain names in the credentials:
So I am doing a query to bring back a list of records, these records have a link to the user that created the record. The link is to the object.
My query gets me the object but I cant then access the fields of that object (except of course ID)
query.equalTo("search", search);
query.include("user");
query.find({
success: function(Report) {
for (var i = 0; i < Report.length; i++) {
var test = Report[i].id;
query.get(test, {
success: function(result) {
var reportDescription = result.get("reportDescription");
var reportPicture = result.get("reportPicture");
var reportPosition = result.get("reportPosition");
var reportType = result.get("reportType");
var reportDate = result.get("createdAt").toLocaleString();
var reportSearchId = result.get("search").id;
var user = result.get("user")
console.log(user)
var reportSearchBy = user.username;
},
error: function(result, error) {
alert(error.message);
}
});
};
},
error: function(error) {
alert(error.message);
}
});
What am I doing wrong?
i tried to run similar code to what you did. when i tried to access with dot notation i get undefined but when i tried to get it with .get("fieldName") it works..
here is my code:
var FileTest = Parse.Object.extend("FileTest");
var query = new Parse.Query(FileTest);
query.include("user");
query.find().then(function(results){
var lastItem = results[results.length - 1];
if (lastItem){
var user = lastItem.get("user");
console.log(user.get("username"));
}
},function(error){
});
please notice that i also use Promise for better coding and in order to get the username i did lastItem.get("username")
so please try to replace user.username with user.get("username")
and see if it works.
I have a view composed of a list of users:
#model List<LabelPrinting.Models.UserModel>
and I put these into a JavaScript object:
users = function () { return #Html.Raw(Json.Encode(Model)) }();
I then load a jQuery accordion with the values for each. I then choose to print avery labels for a particular user in the list and set a value. I'm trying to send only that particular user to the controller and am getting a null values for of the user properties:
function PrintAveryLabel(but) {
var id = but.id.substring(9);
var $rad = $(but).closest('tr').siblings().find('.radLabelOther');
if (($rad).is(':checked')) {
var $txtr = $rad.closest('tr').siblings().find('.classRows');
var $txtc = $rad.closest('tr').siblings().find('.classCols');
if ($txtr.val() === "0" || $txtc.val() === "0") {
$("#lblError").text("You have have not selected the rows and columns for the labels.");
$("#MessageDialog").dialog({ title: "Select Rows/Columns" });
$("#MessageDialog").dialog("open");
return false;
}
}
var data = findUser(id);
$.ajax({
type: 'POST',
data: { pat: data },
url: '#Url.Action("PrintUserLabels")'
});
}
The findUser function simply picks the entry in the list that matches the ID.
function findUser(id) {
var data;
for (i = 0; i < cnt; i++) {
if (users[i].UserId === parseInt(id)) {
data = users[i];
break;
}
}
return data;
}
My controller action:
[HttpPost]
public ActionResult PrintUserLabels(UserModel pat)
{
string retval = "";
if (pat.PrintLabel)
{
return RedirectToAction("Label", new { user = pat });
}
else
{
retval = "ERROR - you must make a selection";
Exception e = new Exception(retval);
HandleErrorInfo info = new HandleErrorInfo(e, "DYMO", "PrintPatientLabels");
return RedirectToAction("Error", info);
}
}
The label action is tried and true but I get a null user model. What am I doing wrong?
$('#save').on("click", function() {
//collect the form data while iterating over the inputs
var data = [];
$('[name=form]').find('input, select, textarea').each(function() {
if ($(this).attr('value') != '') {
var name = $(this).attr('name');
var value = $(this).attr('value');
data[name] = value;
}
})
for (var i = 1, ii = form.length; i < ii; i++) {
var name = 'form' + i;
$('[name=' + name + ']').find('input, textarea').each(function() {
data[i] = [];
if ($(this).attr('value') != '') {
var name = $(this).attr('name');
var value = $(this).attr('value');
data[i][name] = value;
}
})
}
$.post('foo', data,
function(data) {
console.log(data);
I have the above jquery code where I wish to post multiple form data into my PHP backend controller.
In my controller, I used
$input = Input::all()
Question 1
How do I access the data in the array that I have passed?
Let's say I have foo input and bar input in my form. I tried to use
$input['foo']
$input['bar']
but I'm getting internal server error with undefined index error.
Question 2
How do I access the data of the data[i][name]? Let's say I have form1, form2, form3, so it my data array will become
$data[1][foo]
$data[2][foo]
$data[3][foo]
How can I access these in my PHP controller?
Thanks and sorry for the long question
with FormData object.
var formdata = new FormData();
formdata.append("name", value);
on server-side you read values like this:
$name = $_POST["name"];