I am trying to access the returned values of a global class method and store them in a string. The string is declared as global static string. The value gets stored in the string when in the method. But when I try use the string in other method of same class, the string is blank/null. There are no values in it.
@RestResource(urlMapping='/xyz/cases/V1/')
global with sharing class controllerc
{
global static string sentresponse;
@HttpPost
global static Casewrapper createNewCase()
{
Casewrapper response= new Casewrapper ();
....
....
sentresponse=string.valueOf(response);
system.debug('^^Sentreposne'+sentresponse); // here the string has returned values.
return response;
}
global static void ErrorMesage()
{
Attachment attachres=new Attachment();
.....
system.debug('++response' + sentresponse); // here the string is null
attachres.Body=Blob.valueOf(sentreponse);
......
insert attachres;
}
}
Please help in how to fetch the response and call it in other method of the same class and assign it to the body of attachment. Thanks in advance.
Regards, Sfdcdev