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
adamproadampro 

Converting ApexTrigger to byte[]

Hi,

 

I'm trying to create an ApexTrigger using the Metadata API. I have the trigger populated with data but I'm having trouble deploying it. I know I need to convert the ApexTrigger to byte[] but don't know how.

 

I tried:

String s = trigger.ToString();
System.Text.ASCIIEncoding encode = new System.Text.ASCIIEncoding();
byte[] bytes = encode.GetBytes(s);

but that doesn't work since ToString() only retrieves the name of the trigger, not the entire thing.

 

Does anyone know how to do this?

 

Thanks. 

SrikanthKuruvaSrikanthKuruva

if you have to get the body of the apex trigger then you have use

triigger.content --> this will return you the trigger body in base64. once you get the trigger.content you can do your remaining logic.