Can't get Author information

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
User avatar
MichaelWeihs
Posts: 2
Joined: Tue Apr 04, 2017

04 Apr 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:

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();

});
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

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

04 Apr 2017

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:

Code: Select all

.author {
  display: none;
}
Next, use JS-code to get e-mail of the author:

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");

User avatar
MichaelWeihs
Posts: 2
Joined: Tue Apr 04, 2017

04 Apr 2017

Worked, thank you!!

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests