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
htdevhtdev 

how to deactivate price book via API

Hi,

I'm trying to create a new deactivated price book via API calls. I was able to create a new pricebook when I do not use the setIsActive() method. When I use the setIsActive() method to create a deactived pricebook, I get the following message:

bad field names on insert/update call: IsActive

So I tried creating a price book in which I specify true instead of false for setIsActive() method, but it still give the same message. I also tried creating a new standard pricebook and try to update the price book. This also fail.

Is there a way to create a new deactivated pricebook? Any help would be greatly appreciated,

Thanks,
htdev

Here is a sniplet of my code:

SObject[] objs = new SObject[1];
Pricebook pb = new Pricebook();
pb.setName(pricebookName);
pb.setIsActive(Boolean.valueOf(false));
SaveResult[] saveResults = null;
try {
saveResults = binding.create(objs);
} catch (UnexpectedErrorFault uef) {
System.out.println("UEF Exception: "+uef.getExceptionMessage() + "\n\n");
return emptyID;
} catch (Exception e) {
System.out.println("Exception:"+e+"\n\n");
//e.printStackTrace();
return emptyID;
}