Hello Surabhi,
Thanks for quick reply.
I am doing another operation also in post install script. Please check below whole code of my post install script.
public class TaxNowPostInstall implements InstallHandler
{
public void onInstall(InstallContext context)
{
if(context.previousVersion() == null) // first install - create a new TaxNow Settings Record
{
//Insert some data when package install
TaxNowSetting__c tns = new TaxNowSetting__c(Name='AvaTax',Active_Setting__c=true,
Service_URL__c = 'https://avatax.avalara.net',TriggerLimit__c = 1);
insert(tns);
//Searching prodcut 'Tax Refund' from product catlog if it is not there, we are inserting it.
List<List<Product2 >>searchList = [FIND :'Tax Refund' RETURNING Product2 ];
Product2 pr = new Product2();
PriceBook2 customPriceBook = new PriceBook2();
if(searchList.size() == 0)
{
pr.Name='Tax Refund';
pr.isActive=true;
pr.ProductCode = 'Tax Refund';
insert pr;
// Insert Pricebook
customPriceBook.Name='Tax Refund';
customPriceBook.IsActive=true;
insert customPriceBook;
}
// Insert Product
List<EntityUse__c> initialCodes = new List<EntityUse__c>
{
new EntityUse__c(Description__c='Non-resident (Canada)', Name ='R'),
new EntityUse__c(Description__c='Commercial Fishery (Canada)', Name ='Q'),
new EntityUse__c(Description__c='Commercial aquaculture (Canada)', Name ='P'),
new EntityUse__c(Description__c='Other (requires Exempt Reason Desc) (both)', Name ='L'),
new EntityUse__c(Description__c='Direct mail (United States)', Name ='K'),
new EntityUse__c(Description__c='Direct pay permit (United States)', Name ='J'),
new EntityUse__c(Description__c='Industrial production / manufacturer (both)', Name ='I'),
new EntityUse__c(Description__c='Commercial agricultural production (both)', Name ='H'),
new EntityUse__c(Description__c='Resale (both)', Name ='G'),
new EntityUse__c(Description__c='Religious or educational org (both)', Name ='F'),
new EntityUse__c(Description__c='Charitable or benevolent org (both)', Name ='E'),
new EntityUse__c(Description__c='Foreign diplomat (both)', Name ='D'),
new EntityUse__c(Description__c='Tribe / Status Indian / Indian Band (both)', Name ='C'),
new EntityUse__c(Description__c='State government (United States)', Name ='B'),
new EntityUse__c(Description__c='Federal government (United States)',Name='A')
};
insert initialCodes;
List<Shipping_Codes__c> initialsCodes = new List<Shipping_Codes__c>
{
new Shipping_Codes__c(Description__c='Delivery by company vehicle before passage of title', Name ='FR010000'),
new Shipping_Codes__c(Description__c='After passage of title', Name ='FR010100'),
new Shipping_Codes__c(Description__c='Shipping Only (Not paid directly to common carrier)', Name ='FR010200'),
new Shipping_Codes__c(Description__c='Common carrier - FOB destination', Name ='FR020000'),
new Shipping_Codes__c(Description__c='Common carrier - FOB origin', Name ='FR020100'),
new Shipping_Codes__c(Description__c='Common carrier - FOB unknown', Name ='FR020200'),
new Shipping_Codes__c(Description__c='Non-common carrier - FOB destination', Name ='FR020300'),
new Shipping_Codes__c(Description__c='Non-common carrier - FOB origin', Name ='FR020400'),
new Shipping_Codes__c(Description__c='Non-common carrier - FOB unknown', Name ='FR020500'),
new Shipping_Codes__c(Description__c='Direct Mail-printed material for mass audience delivery', Name ='FR020600'),
new Shipping_Codes__c(Description__c='Charges that exceed the actual cost of delivery', Name ='FR020700'),
new Shipping_Codes__c(Description__c='Charges that exceed reasonable and prevailing rates', Name ='FR020800'),
new Shipping_Codes__c(Description__c='Shipping And Handling Combined', Name ='FR020900'),
new Shipping_Codes__c(Description__c='Common carrier - FOB destination', Name ='FR030000'),
new Shipping_Codes__c(Description__c='Common carrier - FOB origin',Name='FR030100'),
new Shipping_Codes__c(Description__c='Common carrier - FOB unknown', Name ='FR030200'),
new Shipping_Codes__c(Description__c='Non-common carrier - FOB destination', Name ='FR030300'),
new Shipping_Codes__c(Description__c='Non-common carrier - FOB origin', Name ='FR030400'),
new Shipping_Codes__c(Description__c='Non-common carrier - FOB unknown', Name ='FR030500'),
new Shipping_Codes__c(Description__c='Direct Mail-printed material for mass audience delivery', Name ='FR030600'),
new Shipping_Codes__c(Description__c='Charges that exceed the actual cost of delivery', Name ='FR030700'),
new Shipping_Codes__c(Description__c='Charges that exceed reasonable and prevailing rates', Name ='FR030800'),
new Shipping_Codes__c(Description__c='Electronically Delivered', Name ='FR030900'),
new Shipping_Codes__c(Description__c='Temporary Unmapped Freight SKU - taxable default', Name ='FR040000'),
new Shipping_Codes__c(Description__c='Miscellaneous', Name ='FR999999')
};
insert initialsCodes;
}
else // upgrade - make sure all TaxNowSettings have a value in TriggerLimit
{
for(TaxNowSetting__c tns : [select TriggerLimit__c from TaxNowSetting__c])
{
//once avalara package install, we insert TriggerLimit == 1 by default.
if(tns.TriggerLimit__c == null)
{
tns.TriggerLimit__c = 1;
update(tns);
}
}
}
}
}
Where should i wrote batch function in this script. Please suggest me. If possible please modify it and send me again.