put validation on page item through Dynamic Action - plsql

In this page I have put plsql code on click of Create Assignment button. There is a constraint on column "Assigned To" which usualy fires when that field left blank.
I want to put a validation so that I can get my own alert message which should be user readable. Also after that message submit process should be ignored.
I tried with field name :P11_Assignment NULL in the condition of PLSQL code in Dynamic Action but it is not working.
Please advise with a solution.

Before the PL/SQL Action add an Execute Javascript action.
You will want to use apex.message.* function like the following:
apex.message.clearErrors
apex.message.showErrors
Oracle Documentation link
Example:
apex.message.clearErrors();
if ($v("P11_Assignment").trim() == '') {
apex.message.showErrors({
type: "error",
location: [ "page", "inline" ],
pageItem: "P11_Assignment",
message: 'Must have a Value',
unsafe: false
});
return false; /* This is important, it stops the next action(s) from running. */
}

putting IF ELSE condition in the begining of plsql code
IF field is empty THEN don't execute the plsql code and change the field item to a value.
On value change of that item put an alert message in Dynamic Action.

Related

Postprocess input field after submit

I'am building an application with Meteor. I use autoform, but I want to postprocess some inputfields after submit: add leading zeros to a number when converting to a string ( 20 -> "00020" ), change currency values to integers ( $ 20 -> 2000 or $ 21.34 -> 2134 ). I do not see how to do that. Can anybody help me with this? My issue is with triggering the postprocessing. Some examples would be great.
Regards, Roel
add a before hook to your form
From: https://github.com/aldeed/meteor-autoform#callbackshooks:
The before hooks are called after the form is deemed valid but before
the submission operation happens. (The submission operation depends on
the form type.) These hooks are passed the document or modifier as
gathered from the form fields. If necessary they can modify the
document or modifier.
somewhere in your client code where it will be loaded only once, add:
AutoForm.hooks({
myFormId: {
before: {
// Replace `formType` with the form `type` attribute to which this hook applies
formType: function(doc) {
// Potentially alter the doc
doc.foo = 'bar';
// Then return it or pass it to this.result()
//return doc; (synchronous)
//return false; (synchronous, cancel)
//this.result(doc); (asynchronous)
//this.result(false); (asynchronous, cancel)
}
}
});

checkbox update to mongo is sometime work and sometime won't work

My code sometime work and some time won't work
Mongo didn't update sometimes...
But his code is work perfact
What am i do wrong?
Here is my code
http://checkboxploblem.meteor.com
https://github.com/codepawn/practice_makes_perfect/tree/master/checkbox_mongo
origin is
https://github.com/EventedMind/class-build-a-multi-page-app-with-iron-meteor-6737880d
Your problem lies in your event within the 'home.coffee' file:
Template.Home.events
'click [name=isDone]': (e, tmpl) ->
id = #_id
isDone = tmpl.find('input[name=isDone]').checked
Todos.update {_id: id},
$set:
isDone: isDone
You are assigning the first checkbox value to the variable isDone. Thus, if you check the first input box, that is what gets applied to every subsequent task.
You can get around this by retrieving the value of the checkbox from the event object. ie. e.currentTarget.checked
Another alternative is use a unique id for each checkbox and retrieve the value using that id

How to show / validate error of a node listing page

i am trying to save form state in database and want to view in a listing page with its error validation.
i.e, i want to validate a previously saved form state from my database.
this is a node type form .
i had already tried node_validate its not working because i fetch the data before submitting the node . so there is no nid and for that it is not working
and also tried drupal_validate_form but it is showing
[form_token] => The form has become outdated. Copy any unsaved work in the form below and then reload this page
EDIT
Any one with any help , "How to save a form inputs in data base and retrive it from database with out form submision.
Thank You In advance
Any help is most Appreciable.
If you look in Drupal Core, you see this in includes/form.inc at the drupal_validate_form function:
if (isset($form['#token'])) {
if (!drupal_valid_token($form_state['values']['form_token'], $form['#token'])) {
$path = current_path();
$query = drupal_get_query_parameters();
$url = url($path, array('query' => $query));
// Setting this error will cause the form to fail validation.
form_set_error('form_token', t('The form has become outdated. Copy any unsaved work in the form below and then reload this page.', array('#link' => $url)));
// Stop here and don't run any further validation handlers, because they
// could invoke non-safe operations which opens the door for CSRF
// vulnerabilities.
$validated_forms[$form_id] = TRUE;
return;
}
}`
This shows that the "form has become outdated" message is being set here. So, you can make the isset($form[#token']) condition false by unsetting #token to prevent this message from appearing.
All you have to do is load the form state you're going to validate, and call
unset($form[#token']); before you call drupal_validate_form.

Bubble a failed request validation to a controller in MVC

I don't want to disable validation, however it would be great to display a message to a user. Whilst I think it is highly unlikely that a user will ever have a legitimate need to include &# in a text field, I can see someone typing in a free text field something starting with a <.
Is there a way to detect that a validation exception would be thrown and instead display it as a validation message?
Here is the way I resolved this issue:
Create a validation rule, say potentiallyDangerousRequestRule:
var potentiallyDangerousRequestRegex = /[<>]|&#/, // <, >, &#
potentiallyDangerousRequestErrorMessage = 'The error message';
$.validator.addMethod('potentiallyDangerousRequestRule', function (value) {
if (value == '')
return true;
return !potentiallyDangerousRequestRegex.test(value);
}, potentiallyDangerousRequestErrorMessage);
$.validator.unobtrusive.adapters.addBool('potentiallyDangerousRequestRule');
Call validate method on the form element you want to validate:
$('form').validate({errorClass: 'input-validation-error'});
Add the rule to elements, for instance all text inputs and textareas:
$('input:text, textarea').each(function () {
$(this).rules('add', { potentiallyDangerousRequestRule: true });
});
Make sure you call validate method on the form before applying the rule.

ASPxGridview - 'interrupting' row insert events

Hoping someone can point me in the right direction
Using DevExpress ASPxGridView and the Edit form.
I need to 'interrupt' the RowInserting events to warn the user if there's already a record matching their information and allow them to continue or cancel.
I've added the check (and a cancel) to the OnRowInserting event and am using customJSProperties to trigger the popup on the callback.
But I'm stuck on how to get the popups 'yes' button to resume (or restart) the Row Insert.
Is there a way of triggering the editform update event again from client side code?
Or do I need a completely different approach?
First of all, I found this article Use "yes" / "no" in edit mode for boolean value
Second of all, I hope your all rows has a unique value like ID. If so, I sugget a way like this;
Use OnRowInserting function of ASPxGridview. (Find here code examples etc.)
Check your inserting ID is already in your data store or not. (With running a query)
If in your data store or not, use XtraMessageBox like;
XtraMessageBox.Show(“Content”, “Title”, MessageBoxButtons.YesNo);
before that, add DevExpress.XtraEditors namespace. Then you can use it like;
DialogResult myDialogResult;
myDialogResult = XtraMessageBox.Show("Content", "Title", MessageBoxButtons.YesNo);
if (myDialogResult == DialogResult.Yes)
{
//yes was clicked
}
if (myDialogResult == DialogResult.No)
{
//no was clicked
}
Hope it gives you an idea. And If you have Devexpress Licence, you can ask in Devexpress Support. They are really quick and helpful.
You can solve this with custom HttpHandler. Something like this:
press Save button on your edit form
Save initiates httphandler call (from javascript) with data needed for validation (tablename, id). With jquery you can call http handler like this:
if handler returns true continue with save, otherwise show alert with OK/Cancel
if user chooses OK continue with Save
Javascript call with http handler would look like this:
$.ajax({
async: false,
cache: false,
url: 'YourHttpHandler.ashx',
data: { tableName: "your table name", record_id: your_id },
success:
function (data, textStatus, xmlHttpRequest)
{
if(data.result==true)
if(confirm('Continue?'))
{
// continue with save
}
}
});

Resources