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
yuugi linyuugi lin 

Apex classの中でDocumentデータをInsertしましたが、PageReference のControllerの中、該当データ検索できない

Apex中でCSVファイルを作成し、ドキュメントに保存した後、ドキュメントのIDを新しいPageに渡して、ページのコントローラクラス中で該当ドキュメントのデータをSoqlで取得できませんでした。
※Idの渡しができています。
ソースコードが以下になります。
  1. document = new Document();
  2. document.Name = FileName;
  3. document.FolderId = folder.Id;                    
  4. document.Body = Blob.valueOf('test');
  5. document.Type = 'csv';
  6. document.ContentType='text/csv';
  7. insert document;
  8. PageReference csvpage = page.ConvertPage;
  9. csvpage.getParameters().put('str', document.id);
  10. ページのコントローラクラス:
  11. global class Convert{
  12. public String csvId {get;set;}
  13. public String csvtext {get;set;}
  14. // コンストラクタ
  15. public Convert() {
  16. this.csvId =ApexPages.currentPage().getParameters().get('str');
  17. Document d = [SELECT Id, Body from document where Id =: csvId];
  18. csvtext = d.Body.toString();
  19. }
  20. }
16番のIDはありますが、17番のデータが取得できず、エラーとなってしましました。

原因はご存じでしたら、ご教授をお願いいたします。
Taiki YoshikawaTaiki Yoshikawa
処理は特に問題なさそうに思えるのですが一度、パラメータのIDではなく既存ドキュメントデータのIDをセットしてデータ取得が可能か確認してみるのが良さそうです。

そこで問題がなければ、クエリや権限の問題では無いことが確認できますので、ページ遷移による値渡しの方法を見直す必要がある気がします。