Menu
SuiteCRM dedicated support by SalesAgility
Welcome, Guest
Username: Password: Remember me

TOPIC: How to ask 'Are you sure?' alert

How to ask 'Are you sure?' alert 5 days 33 minutes ago #75312

  • alessandro.marcioni
  • alessandro.marcioni's Avatar
  • Offline
  • New Member
  • Posts: 18
  • Thank you received: 1
  • Karma: 0
Hello everybody,
i'm here again asking you (i hope) a simple thing.
When i save an aos_quotes (related to an account record), if a field in accounts_cstm.field is null or != '', i want to generate an alert box that says 'Are you sure?'.
Is there a way upgrade safe?
Thankyou again! :cheer:
The administrator has disabled public write access.

How to ask 'Are you sure?' alert 4 days 23 hours ago #75318

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 8557
  • Thank you received: 1307
  • Karma: 311

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.
The following user(s) said Thank You: alessandro.marcioni

How to ask 'Are you sure?' alert 4 days 18 hours ago #75323

  • alessandro.marcioni
  • alessandro.marcioni's Avatar
  • Offline
  • New Member
  • Posts: 18
  • Thank you received: 1
  • Karma: 0
That could Be a great solution :cheer:
But in your opinione how can i insert a field from a related module in the if condition script?
The administrator has disabled public write access.

How to ask 'Are you sure?' alert 4 days 5 hours ago #75332

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 8557
  • Thank you received: 1307
  • Karma: 311
You can do anything, but since you're in the front-end, to avoid making things too complicated it would be helpful if you had that data already available there.

Sometimes a workaround is better, like adding a custom field to this record, and populating it in a Workflow every time the related record is updated. This way you have the information from the related record always nearby, in the current record.

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.
The following user(s) said Thank You: alessandro.marcioni

How to ask 'Are you sure?' alert 4 days 5 hours ago #75333

  • alessandro.marcioni
  • alessandro.marcioni's Avatar
  • Offline
  • New Member
  • Posts: 18
  • Thank you received: 1
  • Karma: 0
Ok pgr, thankyou for your advice.
I've created a beforesave logichook that print the accounts field in the quote.
So now i've that value in this module; but how can i show the alert 'The field ERP NOTE is not empty, are you sure you want to save?'
How can i menage the correct sequence of actions?
Thank you, you're kind :cheer:
Last Edit: 4 days 5 hours ago by alessandro.marcioni.
The administrator has disabled public write access.

How to ask 'Are you sure?' alert 2 days 21 hours ago #75350

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 8557
  • Thank you received: 1307
  • Karma: 311
Have you tried the Javascript in the example at that blog I linked? It seems to be adding an error message, see how it is displayed, it's probably similar to what you need...

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.

How to ask 'Are you sure?' alert 1 day 21 hours ago #75400

  • alessandro.marcioni
  • alessandro.marcioni's Avatar
  • Offline
  • New Member
  • Posts: 18
  • Thank you received: 1
  • Karma: 0
Ok, i give you an update.
I've created a logichook before_save that brings the field from the Account module to the AOS_quotes module.
Then i've created another logichook after_save that shows the alert only if that field is not empty (EDIT: the alert i need is not an 'Are you sure?' alert. It is just an 'Ok' alert).

The function of the first logichook works well.

The function of second logichook works not totally:
it works only when i make an In Line Edit; when i click on Actions -> Edit -> Save , none of alert is displayed.
I show you all the file i made:

Logichook
<?php
$hook_version = 1;
$hook_array = Array();
$hook_array['after_ui_frame'] = Array();
$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(1, 'beforeSaveAOS_Quotes', 'custom/modules/AOS_Products_Quotes/ContrattiAssistenzaAcquistati.php', 'ContrattiAssistenzaAcquistati', 'beforeSaveAOS_Quotes');
$hook_array['before_save'][] = Array(2, 'beforeSaveNazioneUtente', 'custom/modules/AOS_Quotes/NazioneUtente.php', 'NazioneUtente', 'beforeSaveNazioneUtente');
$hook_array['before_save'][] = Array(3, 'beforeSaveBloccoAlyante', 'custom/modules/AOS_Quotes/BloccoAlyante.php', 'BloccoAlyante', 'beforeSaveBloccoAlyante');

$hook_array['after_save'] = Array();
$hook_array['after_save'][] = Array(1, 'afterSave', 'custom/modules/AOS_Quotes/Opportunities_AOS_Quotes_1.php','Opportunities_AOS_Quotes_1', 'afterSave');
$hook_array['after_save'][] = Array(2, 'afterSaveBloccoAlyante', 'custom/modules/AOS_Quotes/Alert.php','AlertAlyante', 'afterSaveBloccoAlyante');
?>

Before_save
<?php
if (! defined('sugarEntry') || ! sugarEntry)
	die('Not A Valid Entry Point');

class BloccoAlyante {

	function beforeSaveBloccoAlyante(&$bean, $event, $arguments) {
		if (! empty($bean->billing_account_id)) {
			$beanAzienda = BeanFactory::getBean('Accounts', $bean->billing_account_id);
			if (! empty($beanAzienda))
				$bean->blocco_alyante_c = $beanAzienda->blocco_alyante_c;
			}
	}
}
?>

After_save
<?php
if (! defined('sugarEntry') || ! sugarEntry)
	die('Not A Valid Entry Point');

class AlertAlyante {

	function afterSaveBloccoAlyante(&$bean, $event, $arguments) {
		if (! empty($bean->blocco_alyante_c)) {
            $blocco_alyante = $bean->blocco_alyante_c;
		    $message = "Attenzione, questo cliente ha un Blocco Alyante: $blocco_alyante";
            echo "<script type='text/javascript'>alert('$message');</script>";
            }
		}
	}
?>
The administrator has disabled public write access.

How to ask 'Are you sure?' alert 1 day 8 hours ago #75407

  • alessandro.marcioni
  • alessandro.marcioni's Avatar
  • Offline
  • New Member
  • Posts: 18
  • Thank you received: 1
  • Karma: 0
UPDATE: I found a different solution using SugarApplication::appendErrorMessage($message) instead of window.alert($message).
The administrator has disabled public write access.
Time to create page: 0.078 seconds
Powered by Kunena Forum