Page 1 of 2

Send Sharable Link Code

Posted: Thu Sep 30, 2021 11:57 am
by pmjd
Hello,

I've been looking at the Code Library to try and implement the Get a Sharable Link to Record code.
https://github.com/nuBuilder/nuBuilder- ... _of_record

Anyone know how this works and can be implimented as a button on a record? I've tried pasting it into the custom form code but just not sure what else it needs to get it working.

The most recent version looks very different to the previous versions.

Thanks,
Paul

Re: Send Sharable Link Code

Posted: Thu Sep 30, 2021 12:10 pm
by kev1n
Paul, as it's a PHP code, you can create a procedure an run it with

Code: Select all

nuRunPHPHidden('your_procedure_code_here',0)

Re: Send Sharable Link Code

Posted: Thu Sep 30, 2021 12:23 pm
by pmjd
Thanks kev1n but not too sure on the requirements for it?

Code: Select all

// 1. Argument ($origin): Leaving it blank, nuGetHttpOrigin() will be used to retrieve the domain (HTTP_ORIGIN or HTTP_REFERER or REMOTE_ADDR)
// 2. Argument ($subFolder): Leave blank if index.php is in the root.
$recordURL = nuGetRecordURL('', '', 'nuuserhome'); 

$r = nuSendEmail('to@test.com', 'from@test.com', 'From Name', 'Body' . $recordURL, 'Subject', [], true, '', '');
It's not clear what the two arguments are and what you need to do with them. Also does this result in a popup so you can set the recipient, message etc?

Re: Send Sharable Link Code

Posted: Thu Sep 30, 2021 12:48 pm
by pmjd
Should have said I tried the code in a procedure as is but nothing happens.

My nuBuilder currently runs on http://localhost/nubuilder, so not in the root as such. I've tried putting both

Code: Select all

nubuilder
and

Code: Select all

/nubuilder
in the second empty ' ' but doesn't seem to have any effect.

Re: Send Sharable Link Code

Posted: Thu Sep 30, 2021 1:08 pm
by kev1n
The procedure's PHP code should look like this:

Code: Select all

$recordURL = nuGetRecordURL('', 'nubuilder', 'nuuserhome');
$r = nuSendEmail('to@test.com', 'from@test.com', 'From Name', 'Body' . $recordURL, 'Subject', [], true, '', '');
E.g. with the procedure code sendlink

To run the procedure (e.g. add to a button's onlick event):

nuRunPHPHidden('sendlink',0); You will need the latest nucommon.php since I just fixed a bug.

Re: Send Sharable Link Code

Posted: Thu Sep 30, 2021 1:30 pm
by pmjd
Thanks kev1n, I've updated the system but still no luck.

I've tried the code you posted but onclick does nothing.

Just to check that I've not misread/misunderstood but this code is meant to send an email with a link to a record from that record?

Re: Send Sharable Link Code

Posted: Thu Sep 30, 2021 2:56 pm
by kev1n
pmjd wrote:Just to check that I've not misread/misunderstood but this code is meant to send an email with a link to a record from that record?
Yes, exactly. I just tested the code and it works fine for me. I suppose you have entered the email config details under Setup -> Email Settings.
Can you show screenshots of your onclick event code + PHP procedure code? You can mask private data of course.

Re: Send Sharable Link Code

Posted: Thu Sep 30, 2021 4:01 pm
by pmjd
Have checked and a test email is sent from nuBuilder and received.

The procedure code is
Screenshot 2021-09-30 at 14-55-57 LotGen Beta - sendlink.png
and the onclick code

Re: Send Sharable Link Code

Posted: Thu Sep 30, 2021 4:03 pm
by kev1n
Does that mean it works?

Re: Send Sharable Link Code

Posted: Thu Sep 30, 2021 6:30 pm
by pmjd
Sorry afraid not, I meant a test email sent from the nuBuilder email setup screen sends successfully but the sharable link doesn't work.