connect to sugarcrm and get some data in my custom php file

I made in new custom php file lets say e.g sample.php placed in root folder accessing it through a ajax call in any module but i am not able to connect to database or perform any operation. How to do that anyone can help?

Parents Reply
  • Yes Umar, As I have posted  you can pass current user id as a post variable while making ajax call.

    And apply following code in your sample.php file.

    <?php

    if(!defined('sugarEntry'))

      define('sugarEntry', true);

    require_once ('include/entryPoint.php');

    global $db, $current_user;

    $userId = $_REQUEST['userId'];

    if(empty($current_user->id)){

      $current_user->retrieve($userId);

    }

    $name = $current_user->name;

    echo $name;

    ?>

Children