Access Data entity through URL X++ Code

 


Access Data entity through URL X++ Code


public static void main(Args _args)
{
    FMLabCustomerEntity customer;
    str license = "License";
    Random r = new Random();
    int rand = r.nextInt();
    license = license + int2str(rand);

    //Create a new record in FM lab customer entity
    customer.clear();
    customer.FirstName = "Bob";
    customer.LastName = "Smith";
    customer.DriversLicense = license;
    customer.insert();

    info(strfmt("Tried to insert customer '%1 %2' with license %3", 
        customer.FirstName, customer.LastName, customer.DriversLicense));

    //Display newly created record
    select forupdate customer where customer.DriversLicense==license;
    info(strfmt("Found newly created customer '%1 %2' with license %3", 
        customer.FirstName, customer.LastName, customer.DriversLicense));

    //Now delete the record from the entity
    customer.delete();
    select customer where customer.DriversLicense==license ;
    info(strfmt("Deleted customer does not exist: license- %1", customer.DriversLicense));
}

Comments