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?
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?
plus print current_user it come up wd details of logged in user.
whats wrong with $name = $current_user->name; ?
So I think now using this $db you can perform any mysql operations.
For current user I have checked that,
you have to pass current user id as a POST variable to access in ajax file and get all info using retrieve function.
Hi Umar and Devang,
I dont find 'name' field in users table.
Can you try check with $current_user->first_name?
Thanks!.
Hi Ajay
current_user is not accessible in this case.
For current user I have checked that,
You have to pass current user id as a POST variable to access in ajax file and get all info using retrieve function.
Try with this,
<?php
if(!defined('sugarEntry'))
define('sugarEntry', true);
ini_set("display_errors", 1);
require_once ('include/entryPoint.php');
global $db, $current_user;
$userId = $_REQUEST['userId'];
if(empty($current_user->id)){
$current_user->retrieve($userId);
}
Devang any solution buddy?
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;
?>
Hello Devang,
With your logic i am able to access properties of logged in user. Thank You so much
Now kindly please tell me how to do query in my sample_info.php page ?
Hello Devang,
Buddy i have done that query thing used the $db variable ..Thankyou so much once again