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
kmatskmats 

Chatter Workbook page11の実装でNo such columnエラー

Chatter Workbook page11の下記の実装でNo such columnエラーが発生し、workを進めることができません。

 

アカウントの設定はChatter Workbookに従って Developer Editionを取得して行い、特別な変更は行っていません。

開発はworkbookどおりブラウザのページエディタの、コントローラ編集タブで行っています。

 

ソースコード:

public with sharing class SafeInputController {

    public PageReference go() {
        User user = [select id, CurrentStatus from User where id = :UserInfo.getUserId()];
        user.CurrentStatus = status;
        update user;
        return null;
    }

    public String status { get; set; }
}

 

エラー:

SafeInputController コンパイルエラー: 行 4、列 21 でNo such column 'CurrentStatus' on entity 'User'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

 

何か設定等でchatter関連開発に必須の手順を飛ばしてしまったか、暗黙の条件を知らずに参照等の制限を外せていない(または手違いで制限してしまった)などがあるだろうかと調べています。

原因、対処方法にお心当たりの方、ぜひご教示ください。どうぞよろしくお願いいたします。

Best Answer chosen by Admin (Salesforce Developers) 
takahiro-yoneitakahiro-yonei

リファレンスを確認すると、「CurrentStatus」はv25.0で使用不可になってるみたいですね。

 

"This field is deprecated in API version 25.0. To achieve similar behavior, post to the user directly by creating a FeedItem with the user’s ParentId."

UserObject(リファレンス) 

 

 

APIのバージョンを24.0等に指定すれば、Workbookの通りに進められると思います。

ご確認のほど、よろしくお願いします。

All Answers

takahiro-yoneitakahiro-yonei

リファレンスを確認すると、「CurrentStatus」はv25.0で使用不可になってるみたいですね。

 

"This field is deprecated in API version 25.0. To achieve similar behavior, post to the user directly by creating a FeedItem with the user’s ParentId."

UserObject(リファレンス) 

 

 

APIのバージョンを24.0等に指定すれば、Workbookの通りに進められると思います。

ご確認のほど、よろしくお願いします。

This was selected as the best answer
kmatskmats

さっそくありがとうございます!FeedItemを使うことにし、go()メソッドを以下に変更したところ動作しました。

 

    public PageReference go() {
        User user = [select id from User where id = :UserInfo.getUserId()];
        FeedItem post = new FeedItem();
        post.ParentId = user.id;
        post.Body = status;
        insert post;
        return null;
    }