Dynamic Links/Variable?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • khopper
    Senior Member
    • Sep 2017
    • 329

    Dynamic Links/Variable?

    I see that I can add a URL field type, however is it possible to make a link dynamic like the quotes and email templates.

    I saw this link but it wasn't very helpful: http://forum.espocrm.com/forum/devel...amic-url-field

    For instance take an ordinary link and insert a variable: http://127.0.0.1/espocrm/phpexcel-export.php/{Account.id}

    To equal something like this: http://127.0.0.1/espocrm/phpexcel-ex...561ab32eedc5e2

    Thank you in advance!
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    Hello

    At first, I recommend you to use entryPoint. In this case you will stay in system, but not working outside.application/Espo/EntryPoints/Pdf.php - as example.
    this link is built in view, in view you have access to entity Id, so you can paste it /client/src/views/fields/file.js

    Comment

    • khopper
      Senior Member
      • Sep 2017
      • 329

      #3
      I am afraid I am not following you on this one, sorry!
      Maybe explain differently please? & thank you!

      Comment

      • khopper
        Senior Member
        • Sep 2017
        • 329

        #4
        Never Mind! I was having a blonde moment! I threw this Formula together and it worked perfectly in a newly created read only URL field called "urlgensow"
        urlgensow = string\concatenate("http://localhost/phpexcel/test3.php?accountid1=",id);
        it generated the following URL link
        http://localhost/phpexcel/test3.php?accountid1=59f9001de9e7ea991

        Comment


        • crmclients
          crmclients commented
          Editing a comment
          This helped me with a link for one of my fields for logins, thanks for sharing
      • khopper
        Senior Member
        • Sep 2017
        • 329

        #5
        For anyone else searching the Forums here are the contents of the test3.php file that pull from the DB to an XLSX file which can be customized (I'm not done yet!)

        <?php
        require_once 'Classes/PHPExcel.php';

        //database connection (using mysqli)
        $con = mysqli_connect("localhost","root","whatever","espo crm");
        if(!$con){
        echo mysqli_error($con);
        exit;
        }

        //You can read your excel template like this with PHPExcel:
        //$objPHPExcel = PHPExcel_IOFactory::load("./forms/english/cash.xlsx");
        //and you can write to cells like this:
        //$objPHPExcel->setActiveSheetIndex(0)
        // ->setCellValue('A2', "No")
        // ->setCellValue('B2', "Name")
        // ->setCellValue('C2', "Email")
        // ->setCellValue('D2', "Phone")
        // ->setCellValue('E2', "Address");

        //create PHPExcel object
        $excel = new PHPExcel();

        //insert some data to the PHPExcel object - Select Active Sheet
        $excel->setActiveSheetIndex(0);

        //get variable from url
        $accountid = $_GET['accountid1'];

        //populate the data
        $query = mysqli_query($con,"SELECT * FROM account WHERE id='$accountid'");
        $row =4;
        while($data = mysqli_fetch_object($query)){
        $excel->getActiveSheet()
        ->setCellValue('A'.$row , $data->name)
        ->setCellValue('B'.$row , $data->btn)
        ->setCellValue('C'.$row , $data->salestatus)
        ->setCellValue('D'.$row , $data->orderdate);
        //increment the row
        $row++;
        }

        //redirect to browser (download) instead of saving the result as a local file on server
        header('Content-Type: application/vnd.openxmlformats-officedoucment.spreadsheetml.sheet');
        header('Content-Disposition: attachment; filename="scope_of_work.xlsx"');
        header('Cache-Control: max-age=0');

        //write the result to a file
        $file = PHPExcel_IOFactory::createWriter($excel,'Excel2007 ');
        //output to php optput instead of filename
        $file->save('php://output');

        ?>

        Comment


        • tanya
          tanya commented
          Editing a comment
          BTW, If your Espocrm is available in global network, anybody can download this file
      • khopper
        Senior Member
        • Sep 2017
        • 329

        #6
        It is not global, however how would I restrict it to only ESPO users to be able to access?

        Comment

        • tanya
          Senior Member
          • Jun 2014
          • 4308

          #7
          with entry points, which I reminded before. You have paths with exapmles

          Comment

          • khopper
            Senior Member
            • Sep 2017
            • 329

            #8
            are you saying that i just move my PHP file into the entry points location and run it from there?

            Comment

            • tanya
              Senior Member
              • Jun 2014
              • 4308

              #9
              I wrote you 2 paths application/Espo/EntryPoints/Pdf.php - backend, /client/src/views/fields/file.js - frontend
              open frontend file and find 'entryPoint' - you will see the url, you need to build
              in the dir of backend file create your file, open an example and write yours

              Comment

              • khopper
                Senior Member
                • Sep 2017
                • 329

                #10
                I found "getDownloadUrl" in the file.js searching for "entryPoint" ?
                I still do not understand how to call the "getDownloadUrl" function from within ESPO itself.
                I created my own backend file "Xlsx.php" using Pdf.php as an example --> how do I get the DownloadUrl to point to the Xlsx.php?

                248 getDownloadUrl: function (id) {
                var url = this.getBasePath() + '?entryPoint=download&id=' + id;
                if (this.getUser().get('portalId')) {
                url += '&portalId=' + this.getUser().get('portalId');
                }
                253 return url;

                I'm still new to all this PHP and JS stuff

                Comment

                • tanya
                  Senior Member
                  • Jun 2014
                  • 4308

                  #11
                  Hi! I'm trying to implement a custom button with action on it (as entryPoint) The code in detail.js: Espo.define('custom:views/style-expert

                  Hello, I have created a custom entity and I have figured out how to get a custom button on the page now, but I would like to create a script to

                  Comment

                  Working...