Announcement

Collapse
No announcement yet.

macro's in library

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • macro's in library

    Question is simple: can I or can't I use scriptcase macro's while working on my own library. If so, why are the default macro's not shown and do I only have a blanc form? I need to do database access and it's the most convenient if I can do that in the same consistant way as SC does itself.

    If I use macro's I get the message:

    This library contains codes out of the functions that will only be processed through the sc_include macro.

    but what does that mean? Is it an errormessage, do I have to use the sc_include ...

    If I do so then I get an errormessage:

    Fatal error: Non-abstract method ad_form_case_apl::startcase() must contain body in C:\Program Files (x86)\NetMake\v6\wwwroot\scriptcase\app\RugMutPers \ad_form_case\ad_form_case_apl.php on line 4360

    with this library function:

    <?php
    // start workflow case
    function startcase($emplid, $flowid);
    {
    // Insert record
    $insert_sql = 'INSERT INTO MUTF_CASE (case_id, startdate, emplid, flowid, case_status, case_flowstep) values'
    . ' (seq_mutf_case, to_char (SYSDATE, "MM-DD-YYYY HH:MI:SS"), "'.$emplid.'","'.$flowid.'", "O", 0)';

    sc_exec_sql($insert_sql);
    }
    ?>

    called in the onvalidate:

    sc_include('wf_rout.php');
    startcase('a','b');
    Last edited by aducom; 11-26-2012, 07:36 AM.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

  • #2
    Hello Mr. Drent,

    Yes you can use sc_macros on libraries as long as you won't call a library that uses a sc_macro on an event the macro does not work.

    Let's take sc_set_focus for instance, it works on a few Control and Form events. It doesn't make sense to call a library that uses sc_set_focus on the onExecute() of a menu application.

    Please see this tutorial. It explains how you can create and use a library referencing sc_macros in it.

    regards,
    Bernhard Bernsmann

    Comment


    • #3
      Hi mr. Bartho,

      Please read the question a bit better. I know that there are macro's you can use within libraries as sc_redir works w.o. problems. And of course you cannot use certain macro's in certain events. *But* you cannot use database access from within the libraries because these macro's simply do not work but generates warnings and errors. Thats a big problem and it has been acknowledged by the support team as a bug. I.e. I want to have some routines to manage workflow. To start a workflow case there are several triggers within my application. Putting them in a library means that anybody from any application can use these. Now you have to put all sourcecode in every event causing a lot of code, lot of managable spots and lots of work if things needs to change. There's realy no use for libraries if you cannot access the database from there using the same connection as within scriptcase modules!

      Even within events, the database must be able to be accessed... any place... any time! Or it should be if you need to use it before the database is initialized. Than you have a problem ;-)

      b.r. Albert
      Last edited by aducom; 11-28-2012, 05:58 AM.
      Albert Drent
      aducom software netherlands
      scriptcase partner, reseller, support and (turn-key) development
      www.scriptcase.eu / www.scriptcase.nl

      Comment


      • #4
        Hello Mr. Drent,

        As you are only calling libraries in events that the macros do work, then those libraries should work.

        What macros are you unable to use on libraries? In which event are you calling those libraries?

        regards,
        Bernhard Bernsmann

        Comment


        • #5
          One movie says more than thousand words...

          http://www.aducom.com/sc.mov
          Albert Drent
          aducom software netherlands
          scriptcase partner, reseller, support and (turn-key) development
          www.scriptcase.eu / www.scriptcase.nl

          Comment


          • #6
            Hello,

            It sure does :P

            I have reported this issue to our bugs team for further testing.

            Additionally, could you try to sc_include this library on the onScriptInit() or onApplicationInit() without calling the function?

            regards,
            Bernhard Bernsmann

            Comment


            • #7
              Hello Mr. Drent,

              Our bugs team got back at me, and they were able to use sc_exec_sql to insert a record.

              Please make sure that your SQL statement is OK, even though looking the video the issue doesn't appear to be caused by that.

              Additionally, please see the steps below to make sure you aren't missing anything:

              Library:

              <?php

              function insert_categories($categoryid, $categoryname, $description, $picture)
              {

              $sql = "INSERT INTO categories VALUES (".$categoryid.",'".$categoryname."','".$descripti on."','".$picture."')";

              sc_exec_sql($sql);

              }

              ?>

              OnValidate():

              {categoryid} = $categoryid;
              {categoryname} = $categoryname;
              {description} = $description;
              {picture} = $picture;

              insert_categories({categoryid},{categoryname},{des cription},{picture});


              With debug mode active, I was able to make sure the insert commited:

              (mysqlt): INSERT INTO categories VALUES (9,'Food','Food Category','')


              If you still face any issue after following the steps above, please contact our support.

              regards,
              Bernhard Bernsmann

              Comment


              • #8
                I will test it again on the current version of scriptcase. I have had a long lasting chat with support and they have verified the problem, they could reproduce it. So this looks like a miracle. But miracles exists.
                Albert Drent
                aducom software netherlands
                scriptcase partner, reseller, support and (turn-key) development
                www.scriptcase.eu / www.scriptcase.nl

                Comment


                • #9
                  Please let me know on any update.

                  It could be happening due to the SQL Statement. I'd start with a simple statement like "INSERT INTO MyTable VALUES (1, 'Test')

                  regards,
                  Bernhard Bernsmann

                  Comment

                  Working...
                  X