function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sabrina Oliveira 3Sabrina Oliveira 3 

Getting value from one method to another

I have this method:
@AuraEnabled    
    public static String updateRecordReturned(Id recordId){
        if (bankaccRcd == null){
            bankaccRcd = [SELECT Id, Status__c, Observations__c FROM Bank_Account_Request__c WHere Id =: recordId];    
        }
        try {
            String stt = bankaccRcd.Status__c; // that's the value I'd like to get to the following method.
            bankaccRcd.Status__c = 'Devolvido';
            update bankaccRcd;    
            FeedItem post = new FeedItem();
            post.Body = 'Devolution: '+bankaccRcd.Observations__c;
            post.ParentId = bankaccRcd.Id;
            insert post;
            return 'Success';
        }catch (DmlException e){
            Return 'Error: '+e.getMessage();
        }
        
    }


I'd like to get the bold value above to another method:

@AuraEnabled    
    public static String updateRecordAfterReturned(Id recordId){
        if (bankaccRcd == null){
            bankaccRcd = [SELECT Id, Status__c, Observations__c FROM Bank_Account_Request__c WHere Id =: recordId];    
        }
        try {
            bankaccRcd.Status__c = stt; // here is where I'd like to get the value above.
            update bankaccRcd;    
            return 'Success';
        }catch (DmlException e){
            Return 'Error: '+e.getMessage();
        }
        
    }

Is it possible?
 
Best Answer chosen by Sabrina Oliveira 3
mukesh guptamukesh gupta
Hi Sabrina,

You need to declarie top side of class

public static void String stt;
public Bank_Account_Request__c bankaccRcd;


if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh 


 

All Answers

mukesh guptamukesh gupta
Hi Sabrina,

You need to declarie top side of class

public static void String stt;
public Bank_Account_Request__c bankaccRcd;


if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh 


 
This was selected as the best answer
Sabrina Oliveira 3Sabrina Oliveira 3
Thank you, Mukesh.. It helped me a lot!