Can't get Author information
- MichaelWeihs
- Posts: 2
- Joined: Tue Apr 04, 2017
Hello,
i have Troubles getting the Author value from my form.
What I want to do is implement a Button to my DisplayForm that just opens a new Mail Form via "Mailto"
Everythings working fine with this Code:
But the Value of Author field is always "undefined" - what am I doing wrong?
And the other question is, is there any smarter and easy way for sending mails, without using an e-mail Client.
All I Need is sending an standard text (always the same) to the author of an element when pressing a button.
Thanks,
Michael
i have Troubles getting the Author value from my form.
What I want to do is implement a Button to my DisplayForm that just opens a new Mail Form via "Mailto"
Everythings working fine with this Code:
Code: Select all
var body_message = $('#message').value;
var email = fd.field('Author').value();
var subject = 'Thementicket: ' + fd.field("Title").value(); +
$('button').click(function() {
var mailto_link = 'mailto:' + email + '?subject=' + subject + '&body=Hier geht es zum Thementicket: http://wkkintranet/Lists/Thementicket/DispForm.aspx?ID='+ GetUrlKeyValue('ID');
win = window.open(mailto_link, 'emailWindow');
if (win && win.open && !win.closed) win.close();
});
And the other question is, is there any smarter and easy way for sending mails, without using an e-mail Client.
All I Need is sending an standard text (always the same) to the author of an element when pressing a button.
Thanks,
Michael
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi Michael,
Put a Plain text control onto your form. Insert the following Text: [Author] and assign a CSS Class, say, author. To hide the control from the form, insert the code into CSS-editor:
Next, use JS-code to get e-mail of the author:
Put a Plain text control onto your form. Insert the following Text: [Author] and assign a CSS Class, say, author. To hide the control from the form, insert the code into CSS-editor:
Code: Select all
.author {
display: none;
}
Code: Select all
SP.SOD.executeOrDelayUntilScriptLoaded((function () {
var id = fd.getUrlParam($('.author a.ms-subtleLink').attr('href'), 'ID');
var ctx = new SP.ClientContext.get_current();
var web = ctx.get_web();
ctx.load(web);
var users = web.get_siteUsers();
var user = users.getById(id);
user.retrieve();
ctx.executeQueryAsync(function () {
alert(user.get_email());
});
}), "SP.js");
-
- Information
-
Who is online
Users browsing this forum: No registered users and 3 guests