Connector Custom Invalid Action Message

Hi all.
I use the connector.
I have an custom update
function …
if … etc etc …

$action->invalid(); $scheduler->event->attach("beforeProcessing", "custom_update");

on the client side I have:

dp.defineAction("invalid", function(xml){ alert("Error Bla bla bla"); return true; });

Can I provide to client side an custom alert message based on different invalid action situation ?

Thank you.



You can set custom attribute which will be added to the related action tag in XML response using set_response_attribute method.
Check out additional information on the data action object page.

Best regards,

Can you provide an example?
I don’t understand the concept.

thank you.



dp.defineAction("invalid", function(xml){ alert("Error Bla bla bla"); return true; });
Here you are receiving reply from the server for the particular event in the xml form. If serialized it looks like this:

"<action type="invalid" sid="71" tid="71"></action>" 

With the help of set_response_attribute method we can add attributes to the xml so later you can build custom logic around them.

For example,


function myUpdate($action){
if($action->get_value(“event_name”)=="") {
$action->set_response_attribute(‘ErrorMessage’,‘Event is missing name.’);
else {
$action->set_response_attribute(‘ErrorMessage’,‘Event is not missing name yet is still somehow incorrect.’);


dp.defineAction("invalid", function(xml){ if(xml.attributes.ErrorMessage) alert(xml.attributes.ErrorMessage.value); else alert('Generic error occured'); return true; });

Now error message set in the xml’s ErrorMessage attribute will be displayed or a generic one if the attribute is missing.

Hope this helps.

Best regards,