Unknown DataField Error

Urgent assistance required
I’m receiving an “Unknown data field ‘UserId’” error in AppendSelectExpressions method in Controller.cs. A further message says "The given key was not present in the dictionary." Yet I have added all these fields to the editForm2 view. The points below give more info.

1. I have created two commands as shown below. Command1 is attached to editForm1 view and command2 is attached to editForm2 view.

<![CDATA[select
"ClinicRight"."UserId" "UserId"
,"User"."UserName" "UserUserName"
,"ClinicRight"."ClinicId" "ClinicId"
,"Clinic"."CentreName" "ClinicCentreName"
,"Clinic"."ClinicCode" "ClinicClinicCode"
,null "Australia"
,null "Japan"
,null "Taiwan"
,null "Korea"
,null "China"
,null "Hongkong"
,null "Singapore"
,null "Malaysia"
,null "Philippines"
,null "Thailand"
,null "Newzealand"
from "dbo"."ClinicRight" "ClinicRight"
left join "dbo"."ClinicUser" "User" on "ClinicRight"."UserId" = "User"."UserId"
left join "dbo"."FMCAP_Table_ThisCentre" "Clinic" on "ClinicRight"."ClinicId" = "Clinic"."ClinicID"
]]>

<![CDATA[select
null "UserId"
,null "UserUserName"
,null "ClinicId"
,null "ClinicCentreName"
,null "ClinicClinicCode"
,null "Australia"
,null "Japan"
,null "Taiwan"
,null "Korea"
,null "China"
,null "Hongkong"
,null "Singapore"
,null "Malaysia"
,null "Philippines"
,null "Thailand"
,null "Newzealand"
]]>

2. I invoke editForm2 using the following action:

3. The above action invokes the following business rule method:
[ControllerAction("ClinicRight", "Custom", "AssignClinic")]
protected void AssignClinic()
{
FieldValue UserIdValue = SelectFieldValueObject("UserId");
Guid userId = new Guid(SelectFieldValue("UserId").ToString());
Int32 clinicId = (Convert.ToInt32(SelectFieldValue("ClinicId")));
if (userId != null)
{
ClinicRight cr = ClinicRight.SelectSingle(userId, clinicId);
Context.Session["ClinicRight"] = cr;
Result.ShowModal("ClinicRight", "editForm2", "Edit", "editForm2");
}
else
Result.ShowAlert("Please select a row.");
}
4. The dataFields, UserId, etc. have been placed in a category called General as shown below:

User details
1 person has
this question
+1
Reply
  • The data controller is not visible in your post.

    Most likely the data field in the view editForm2 refers to a field that is now available "fields" dictionary of the data controller.
    • I have pasted the definition of the dataController. You will see that the Fields list and editForm2 view both include the UserId field:

      <![CDATA[select
      "ClinicRight"."UserId" "UserId"
      ,"User"."UserName" "UserUserName"
      ,"ClinicRight"."ClinicId" "ClinicId"
      ,"Clinic"."CentreName" "ClinicCentreName"
      ,"Clinic"."ClinicCode" "ClinicClinicCode"
      ,null "Australia"
      ,null "Japan"
      ,null "Taiwan"
      ,null "Korea"
      ,null "China"
      ,null "Hongkong"
      ,null "Singapore"
      ,null "Malaysia"
      ,null "Philippines"
      ,null "Thailand"
      ,null "Newzealand"
      from "dbo"."ClinicRight" "ClinicRight"
      left join "dbo"."ClinicUser" "User" on "ClinicRight"."UserId" = "User"."UserId"
      left join "dbo"."FMCAP_Table_ThisCentre" "Clinic" on "ClinicRight"."ClinicId" = "Clinic"."ClinicID"
      ]]>

      <![CDATA[select
      null "UserId"
      ,null "UserUserName"
      ,null "ClinicId"
      ,null "ClinicCentreName"
      ,null "ClinicClinicCode"
      ,null "Australia"
      ,null "Japan"
      ,null "Taiwan"
      ,null "Korea"
      ,null "China"
      ,null "Hongkong"
      ,null "Singapore"
      ,null "Malaysia"
      ,null "Philippines"
      ,null "Thailand"
      ,null "Newzealand"
      ]]>

      $DefaultGridViewDescription

      $DefaultEditViewDescription

      $DefaultEditDescription

      $DefaultReferenceDescription

      $DefaultCreateViewDescription

      $DefaultNewDescription

      User details

      Australian clinics
      <table>
      <tr>
      <td bgcolor=#FFD700>
      {Australia}
      </td>
      </tr>
      </table>

      Japanese clinics
      <table>
      <tr>
      <td bgcolor=#FFF5EE>
      {Japan}
      </td>
      </tr>
      </table>

      Hong Kong clinics
      <table>
      <tr>
      <td bgcolor=#00FF00>
      {Hongkong}
      </td>
      </tr>
      </table>

      Korean clinics
      <table>
      <tr>
      <td bgcolor=#40E0D0>
      {Korea}
      </td>
      </tr>
      </table>

      Taiwanese clinics
      <table>
      <tr>
      <td bgcolor=#00FFFF>
      {Taiwan}
      </td>
      </tr>
      </table>

      Chinese clinics
      <table>
      <tr>
      <td bgcolor=#FF0000>
      {China}
      </td>
      </tr>
      </table>

      Singaporean clinics
      <table>
      <tr>
      <td bgcolor=#00FF00>
      {Singapore}
      </td>
      </tr>
      </table>

      Malaysian clinics
      <table>
      <tr>
      <td bgcolor=#FF00FF>
      {Malaysia}
      </td>
      </tr>
      </table>

      Thai clinics
      <table>
      <tr>
      <td bgcolor=#FFA500>
      {Thailand}
      </td>
      </tr>
      </table>

      Philippine clinics
      <table>
      <tr>
      <td bgcolor=#FFFF00>
      {Philippines}
      </td>
      </tr>
      </table>

      New Zealand clinics
      <table>
      <tr>
      <td bgcolor=#7FFF00>
      {Newzealand}
      </td>
      </tr>
      </table>

      Assign clinics for user
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned sad, anxious, confused, frustrated