%Save() is not saving data into cache DB.

 

I have created below Add method in REST api, I got requested data in objExternalUser object but it is not saved to DB.

Using  "Write objExternalUser.%JSONExport()" I got JSON data.

Please refer below screen.

  • 0
  • 0
  • 75
  • 5
  • 2

Respuestas

Hi @Vivek Nayak!

Always check the status of %Save - it could result in an error. And I think this what was happened in your case.

90% of my "it doesn't save" with %Save caused by MAXLEN of %String property. %String property goes with MAXLEN=50 by default and it's often not enough. Check you have a such ;)

 

 

 

As I see in your code you already do some "error handling". So you can continue:

Change your code

Do objExternalUser.%Save()

to the following:

set stat=objExternalUser.%Save()

if $$$ISERR(stat) {

 #; error handling

 d $System.OBJ.DisplayError(stat)

}

HTH.

Out of curiosity - you have empty Try-Catch block. Why don't use it?

you could embrace your code into the following:

$$$TOE(objExternalUser.%Save())

And catch your error with status in catch then.

Use %VarString instead of %String - it has default length of 3 641 144 characters.

Not that I know of.

If you're sure about MAXLEN it's better to specify it explicitly of course, but if you have no idea %VarString is a nice solution.

I agree. I don't know the reasons which caused to limit the MAXLEN to 50 characters... 

It steals months (if not more) of developers time to find out what was the bug and why this doesn't work because of MAXLEN=50;

Hi Vivek,

%Save() is a function . So please assign it to one variable and check it. Surely it will work.

for ex:  set jData=objExternalUser.%Save()

 

Thanks.