Where can i find the code running in Notes openCreateDrawer? in adding new Record
Version: SugarCRM 7.61
Where can i find the code running in Notes openCreateDrawer? in adding new Record
Version: SugarCRM 7.61
Hi Longki,
Notes module is sidecar now.
Opendrawer (view) will come from record.hbs which is located in /clients/base/views/record/.But if you are looking for any controller related changes ,then you need to go with create-actions.js.
Here is how i am saying opendrawer view will come form record.hbs.
create-actions.js will extendsview from createView.(you can find this from clients/base/views/create-actions/create-actions.js).
create.js will extend view of recordview.(you can find this from /clients/base/views/create/create.js).you can check from where it gets extendsFrom .
So finally (view) it comes record.hbs.Both record and create view will come from this file only.
hope this helps.
Thanks Ajay, it really helped a lot. i already created the ../create-actions/create-actions.js but my problem now is to create an AJAX on it on my new custom API function calling my non-db of my customized fields. im really new to SugarCRM, pls bear with me
Hi Longki
Missing API file error on AJAX call
can you try using api call instead of ajax.The above post will help you.Let us know if you still need more.
i already called the API but i dont know what to put in
$sql= "call <what_to_put_here> ('?','?')";
and
if ($row) {
$json = array( 'valid' => $row['<what_to_put_here>'], 'code' => $row['<what_to_put_here>'], 'error' => $row['errorMessage']);
return json_encode($json);
}
else{
return $db->lastDbError();
}
Hi Longi,
Can you post your js code and api code here? It will be more helpful to figure it out.
Thanks!.
my create-actions.js
({
extendsFrom: 'CreateView',
/**
* @inheritDoc
*/
initialize: function(options) {
options.meta = _.extend({}, app.metadata.getView(null, 'create-actions'), options.meta);
this._super('initialize', [options]);
_.bind(this._getContactFromCases, this);
}
_getContactFromCases: function(callback){
//calling ..rest/v10/Notes/NotesGetContactApi.php
var avatarNameNotes = document.getElementsByName('notes_avatar_name_c')[0].value;
var cidNotes = document.getElementsByName('cid_c')[0].value;
app.api.call('GET', app.api.buildURL("Notes/NotesGetContactApi/"+avatarNameNotes+"/"+cidNotes),null,{
beforeSend: function (request) {
request.setRequestHeader("OAuth-Token", SUGAR.App.api.getOAuthToken());
},
success :function (data){
data = JSON.parse(data);
console.log("AJAX Call successful");
console.log(data);
if (data.valid == 1){
console.log("Result is valid");
}
else {
app.alert.show('ErrorContactInfo',{
level: 'error',
title: 'Error:',
messages: data.error,
}
);
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr);
console.log(ajaxOptions);
console.log(thrownError);
}
}
);
}
})
______________
here is my NotesGetContactApi.php
<?php
require_once('include/api/SugarApi.php');
class NotesGetContactApi extends SugarApi{
public function registerApiRest() {
return array(
'populateFromCasesApi' => array(
'reqType' => 'GET',
'path' => array('Notes', 'GetCaseNote', '?'),
'pathVars' => array('','','notes_avatar_name_c', 'cid_c'),
'method' => 'populateFromCasesApi',
'shortHelp' => 'This method will return the Contact Information of a Case upon creating a Note.',
'longHelp' => '',
),
);
}
public function populateFromCasesApi($api, $args){
global $db;
$sql ="
SELECT
n.avatar_name AS `avatar_name_c`,
n.cid AS `cid_c`,
FROM notes n
LEFT JOIN notes_attachments_linkage l ON l.note_id = n.id
WHERE
n.{$parent_column} = ?
AND n.deleted = 0
AND n.parent_type = 'Cases'
AND n.contact_id = ?
ORDER BY n.date_entered DESC
";
$params = array($args["notes_avatar_name_c"], $args["cid_c"]);
$result = $db->pQuery($sql, $params);
$row = $db->fetchByAssoc($result);
if ($row) {
$json = array( 'valid' => $row['??????'], 'code' => $row['????????'], 'error' => $row['errorMessage']);
return json_encode($json);
}
else{
return $db->lastDbError();
}
}
}
Hi Longki,
I dont think your api will get called.You have defined wrong api path in create-actions.js
app.api.call('GET', app.api.buildURL("Notes/NotesGetContactApi/"+avatarNameNotes+"/"+cidNotes)
It should match with path and pathvars in your api.
So it should be like
app.api.call('GET', app.api.buildURL("Notes/GetCaseNote/"+avatarNameNotes+"/"+cidNotes)
And another correction is ,that you are have defined 3 params in return array path parameter,but you are trying to push 4 params to return array pathvars
So it should be like
'path' => array('Notes', 'GetCaseNote', '?','?'),
'pathVars' => array(' ',' ','notes_avatar_name_c', 'cid_c'),
To summarize your create-actions.js will look like below,
_getContactFromCases: function(callback){ //calling ..rest/v10/Notes/NotesGetContactApi.php var avatarNameNotes = document.getElementsByName('notes_avatar_name_c')[0].value; var cidNotes = document.getElementsByName('cid_c')[0].value; app.api.call('GET', app.api.buildURL("Notes/GetCaseNote/"+avatarNameNotes+"/"+cidNotes),null,{
and your api file will look like
<?php require_once('include/api/SugarApi.php'); class NotesGetContactApi extends SugarApi{ public function registerApiRest() { return array( 'populateFromCasesApi' => array( 'reqType' => 'GET', 'path' => array('Notes','GetCaseNote','?','?'), 'pathVars' => array(' ',' ','notes_avatar_name_c', 'cid_c'), 'method' => 'populateFromCasesApi', 'shortHelp' => 'This method will return the Contact Information of a Case upon creating a Note.', 'longHelp' => '', ), ); } public function populateFromCasesApi($api, $args){
Follow this also :
1.Just print avatarNameNotes and cidNotes to console log(To make sure you are passing value those variables)
2.In populateFromCasesApi function print something to sugarlog(To make sure your api getting called properly)
Hi Longki,
I dont think your api will get called.You have defined wrong api path in create-actions.js
app.api.call('GET', app.api.buildURL("Notes/NotesGetContactApi/"+avatarNameNotes+"/"+cidNotes)
It should match with path and pathvars in your api.
So it should be like
app.api.call('GET', app.api.buildURL("Notes/GetCaseNote/"+avatarNameNotes+"/"+cidNotes)
And another correction is ,that you are have defined 3 params in return array path parameter,but you are trying to push 4 params to return array pathvars
So it should be like
'path' => array('Notes', 'GetCaseNote', '?','?'),
'pathVars' => array(' ',' ','notes_avatar_name_c', 'cid_c'),
To summarize your create-actions.js will look like below,
_getContactFromCases: function(callback){ //calling ..rest/v10/Notes/NotesGetContactApi.php var avatarNameNotes = document.getElementsByName('notes_avatar_name_c')[0].value; var cidNotes = document.getElementsByName('cid_c')[0].value; app.api.call('GET', app.api.buildURL("Notes/GetCaseNote/"+avatarNameNotes+"/"+cidNotes),null,{
and your api file will look like
<?php require_once('include/api/SugarApi.php'); class NotesGetContactApi extends SugarApi{ public function registerApiRest() { return array( 'populateFromCasesApi' => array( 'reqType' => 'GET', 'path' => array('Notes','GetCaseNote','?','?'), 'pathVars' => array(' ',' ','notes_avatar_name_c', 'cid_c'), 'method' => 'populateFromCasesApi', 'shortHelp' => 'This method will return the Contact Information of a Case upon creating a Note.', 'longHelp' => '', ), ); } public function populateFromCasesApi($api, $args){
Follow this also :
1.Just print avatarNameNotes and cidNotes to console log(To make sure you are passing value those variables)
2.In populateFromCasesApi function print something to sugarlog(To make sure your api getting called properly)
thanks a lot Ajay,
How about how to query? can you help me?
Is your query giving expected results? Have you checked?
no. i dont know what value to match coz its non db on a customized filed.. im so sorry im really new to sugarCRM
but i already declared them in custom/Extension/clients/base/vardefs/vardefs.ext.php
Can you explain me the query,what you are trying to fetch (fields) with what condition?
Then we can try with bean or something else.
Because we cant use non-db fields in query right.