Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ListGrid addData custom error message

    SmartCLient v 91p

    Hi,
    I have a ListGrid and I need to perform some custom checks in the DMI before adding a new record.
    If the checks fails, I need to add an error message in the DSResponse;
    on the client side, the addData()'s callback will show the custom error message.

    My js call is like :
    Code:
     listgrig.addData(record, function(dsResponse, data, dsRequest){
     
    	if (dsResponse.status < 0) {
    	  .... show error message
       }else{
    	   ....do something
       }
     },{willHandleError: true});

    DMI server side code is like..:
    Code:
      public Map add(Map record){
    	Map x = new Map();
            DSResponse dsResponse = new DSResponse(); 
    	
    	.... perform custum check...
    	
    	if (..check OK){
    	
    		...add record
    	
    	}else{
    		dsResponse.setStatus(DSResponse.STATUS_FAILURE);
        	        dsResponse.addError("myError", "MyErrorMEssage");	
    	}
    	return x;
      }
    My problem is that, although on server side the dsResponse is correctly set with the error Status ( STATUS_FAILURE ) and message:
    status = -4
    errors = [{myError={errorMessage=MyErrorMEssage}}].

    These attributes 'disappear' on the client side. In the callBAck function, dsResponse status is : 0 and no error message is present.

    Any clue ?

    Thx
    Last edited by lucafranco; 15 Oct 2014, 06:07.

    #2
    See the QuickStart Guide - by calling addError() you have just added a validation error for a specific field. You want to signal a general error.

    Comment

    Working...
    X