Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Passing variables

  1. #1
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Passing variables

    Hi,

    This may be a stupid question but here goes.

    In a logic hook and what to set a variable let say $alert to 1. This will not be a field in Sugar. Then when the detail view is loading and want to be able to check the value of the variable and display and alert if its = to 1. Is something like this possible?

    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  2. #2
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Passing variables

    You could do it a couple of ways and the best answer depends on the end goal. One way is to create/override view.detail.php and after calling parent::display(); output some javascript with the alert if it meets your condition:

    PHP Code:
    function display() {
       
    parent::display();

       if(
    $this->bean->myfield == 1) {
          echo 
    "<script language='javascript'>
                        alert('Uh oh...you did something wrong....');
                   </script>"
    ;
       }


  3. #3
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: Passing variables

    What I do is

    in before_save

    $_SESSION['temporaryData']['errormsg'] = 'My error message ';

    then in view.detail I check for $_SESSION['temporaryData']['errormsg'] and if it exists popup an alert
    Mike Solomon
    Development Manager
    Ivy Ltd
    www.ivy.ltd.uk]www.ivy.ltd.uk

    php version 5.2.6
    MySql 5.1.59

  4. #4
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Re: Passing variables

    Thanks for both answers. I have done the javascript one that eggsurplus describes but this time I'd rather not start creating DB fields that I need to use as flags, I'll give Mikes a go.

    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  5. #5
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Re: Passing variables

    Quote Originally Posted by mikesolomon View Post
    What I do is

    in before_save

    $_SESSION['temporaryData']['errormsg'] = 'My error message ';

    then in view.detail I check for $_SESSION['temporaryData']['errormsg'] and if it exists popup an alert
    Thats worked but how do I then delete variable once I've used if to set of my alert?

    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  6. #6
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: Passing variables

    Quote Originally Posted by chrislynch8 View Post
    Thats worked but how do I then delete variable once I've used if to set of my alert?

    Rgds
    Chris
    unset($_SESSION['temporaryData']['errormsg'] );
    Mike Solomon
    Development Manager
    Ivy Ltd
    www.ivy.ltd.uk]www.ivy.ltd.uk

    php version 5.2.6
    MySql 5.1.59

  7. #7
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Re: Passing variables

    Thanks.

    That seems obvious now - having on of those Fridays.

    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  8. #8
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: Passing variables

    Quote Originally Posted by chrislynch8 View Post
    Thanks.

    That seems obvious now - having on of those Fridays.

    Rgds
    Chris
    You and me both

    other peoples problems are always easier to fix than your own!!!!
    Mike Solomon
    Development Manager
    Ivy Ltd
    www.ivy.ltd.uk]www.ivy.ltd.uk

    php version 5.2.6
    MySql 5.1.59

  9. #9
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Re: Passing variables

    One last thing, seeing as other people problems are easier to solve.

    With Javascript in the view.detail.php how can I redirect the user to the edit view of the record they have just come from?

    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  10. #10
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: Passing variables

    Quote Originally Posted by chrislynch8 View Post
    One last thing, seeing as other people problems are easier to solve.

    With Javascript in the view.detail.php how can I redirect the user to the edit view of the record they have just come from?

    Rgds
    Chris
    If I want to do a redirect I do it in the before save rather than saving & going to detailview

    something like

    if ( empty($_REQUEST['record']) ) {
    SugarApplication::redirect("index.php?module=zz_pb k_cat&return_module=zz_pbk_cat&action=EditView");
    } else {
    SugarApplication::redirect("index.php?module=zz_pb k_cat&return_module=zz_pbk_cat&action=EditView&rec ord=" . $_REQUEST['record']);
    }

    And now I'm off home
    Mike Solomon
    Development Manager
    Ivy Ltd
    www.ivy.ltd.uk]www.ivy.ltd.uk

    php version 5.2.6
    MySql 5.1.59

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Passing a param to ListView
    By krishsugar in forum Developer Help
    Replies: 4
    Last Post: 2010-07-14, 03:41 PM
  2. Passing parameters i in a popupview
    By highres in forum Classifieds
    Replies: 6
    Last Post: 2009-05-13, 02:45 AM
  3. Passing a parameter into a Portal
    By SiebelConvert in forum Developer Help
    Replies: 0
    Last Post: 2009-03-27, 01:28 PM
  4. Passing User Information
    By austints in forum Help
    Replies: 0
    Last Post: 2006-06-19, 06:56 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •