Hey Hey
Shout out to pgr and p.konetskiy - massive help so far in getting me where i am!
What iām trying to achieve is a Pop up message to appear when a Contact record is opened up and thereās an active āSafety Alertā present within the personās record. (My last quest relating to this was to color the fields to highlight them just so and now iām wanting to take it further)
So what Iāve tried so far (unsuccessfully i may add) - just hoping to get a nudge in the right direction.
What Iāve got so far is the directory tree.
SugarPopUp(folder)
manifest.php(file)
-custom(folder)
-include(folder)
-custompop(folder)
custom_popup_js_include.js(file)
customPopUpContacts.js(file)
Iāve got this in my manifest.php
<?php
$manifest = array(
array(
'acceptable_sugar_versions' => array()
),
array(
'acceptable_sugar_flavors' => array()
),
'readme' => 'Please consult the operating manual for detailed installation instructions.',
'key' => 'customSugarMod1',
'author' => 'Mark G',
'description' => 'Adds pop-up Message when a contact has a safety alert.',
'icon' => '',
'is_uninstallable' => true,
'name' => 'Pop-Up Dialog if Safety Alert',
'published_date' => '2023-01-30 12:00:00',
'type' => 'module',
'version' => 'v1.7',
'remove_tables' => 'prompt'
);
$installdefs = array(
'id' => 'customSugarMod1',
'copy' => array(
array(
'from' => '<basepath>/custom/',
'to' => 'custom/'
)
),
'logic_hooks' => array(
array(
'module' => 'Contacts',
'hook' => 'after_ui_frame',
'order' => 1,
'description' => 'Creates pop-up message on load if user inactive',
'file' => 'custom/include/customPopUps/custom_popup_js_include.php',
'class' => 'CustomPopJs',
'function' => 'getContactJs'
)
)
);
And iāve got this in the include php file
<?php
if (! defined('sugarEntry') || ! sugarEntry) {
die('Not a valid entry point.');
}
class CustomPopJs {
function getContactJs($event, $arguments) {
if ($_REQUEST['action'] != 'EditView') {
return;
}
echo '<script type="text/javascript" src="custom/include/customPopUps/customPopUpContacts.js"></script>';
}
}
And this is in the javascript thatās called.
document.addEventListener('DOMContentLoaded', function() {
checkUserStatus();
}, false);
function checkUserStatus()
{
if($("#safetyalert_c").val() != "YES" )
{
YAHOO.SUGAR.MessageBox.show({msg: 'There is an active safety alert present! ', title: 'Safety Alert!'} );
}
}
The database field exactly is āsafetyalert_cā in contacts_cstm and thatās a field setup in studio as a dropdown āYESā or āNOā value - thatās what it looks like in the DB (field & value)
Am i going down the right train tracks?
Many thanks for your continued support! <3