4

Please i need a help to resolve my problem: i need to insert a new record but i have the error message => Field is not writeable: Report.Name

that's my function to insert a new record

public static void initReport(){
    Report R =new Report(Name='Survey with Questions and Responses',Format='Summary',OwnerId='00l40000001ACJdAAO' );
    insert R; 
}
1
  • So your application wants to dynamically create Report metadata?
    – cropredy
    Commented Dec 10, 2014 at 17:49

2 Answers 2

3

You just generally can't insert a Report through code. You will get that same error on every field. It just says Name because that is the first field you are specifying.

3
  • 3
    In other words, use the metadata API.
    – sfdcfox
    Commented Dec 10, 2014 at 16:47
  • If i need to insert anew record what can I do ??
    – muzin
    Commented Dec 10, 2014 at 16:52
  • You could use a metadata API wrapper such as this one by Andrew Fawcett.
    – Venko
    Commented Dec 10, 2014 at 17:18
2

As dphil says you cannot insert a report through vanilla Apex.

You can however use a Metadata API wrapper such as this one by Andrew Fawcett.

You must log in to answer this question.

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