0

Hi we have a @future class created, however we have this error as per the screen shot below

enter image description here

Please find the code below

public with sharing class Addressfuture {

public Addressfuture()
{
    List<String> Addresses = new List<String>();
    AddressHelper obj1 = new AddressHelper('1 hase st','san Francisco','CA','94105');
    AddressHelper obj2 = new AddressHelper('2 hase st','San francisco','CA','94105');
    AddressHelper obj3 = new AddressHelper('3 hase st','San francisco','CA','94105');

    Addresses.add(JSON.serialize(obj1));
    Addresses.add(JSON.serialize(obj2));
    Addresses.add(JSON.serialize(obj3));
    callfuture(Addresses);
}

@future
Static void callfuture(List<String> Addresses)
{
    Address currAddress = null;
    for(String sur: Addresses)
    {
        currAddress =(Address)JSON.deserialize(sur,AddressHelper.class);
        system.debug('Deserialized in future:' +currAddress.street);
    }
}

}

public with Sharing class Address {

public string street{get;set;}
public string city{get;set;}
public string state{get;set;}
public string zip{get;set;}

Public Address(string s,String c,String st,String z)
{
    Street = s;
    City = c;
    State = st;
    Zip = z;
}

}

Please advise

Thanks,

2
  • 2
    Can you also post the code of AddressHelper class?
    – Mr.Frodo
    Sep 10, 2018 at 11:14
  • Where is your AddressHelper class defined? The error you're seeing occurs because the AddressHelper class isn't accessible in the code you're calling it from. Sep 10, 2018 at 11:16

1 Answer 1

0

You need to use constructor of Address class, instead you are looking for AddressHelper. Please correct it in your code and it would work.

Instead of

AddressHelper obj1 = new AddressHelper('1 hase st','san Francisco','CA','94105');

use:

Address obj1 = new Address('1 hase st','san Francisco','CA','94105');

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .