0

I want to display a custom field (Rich Text Image) from User to approval History related list which will display the scanned signature of an Approver in aproval process. The Message i get when i add the Signature__c field is "Invalid field Signature__c for SObject Name. But When it works for Standard field Like First Name. I notice that Signature__c is a custuom field of User object Here is my code

<table border="0" >
           <tr>
            <th>Approver</th> 
            <th>Status</th> 
             <th>Comments</th> 
            <th>Signature</th>
           
        </tr>
        <apex:repeat var="cx" value="{!Material_Request__c.ProcessSteps}">
            <tr>
                
            <td>{!cx.Actor.Name}</td> 
            <td>{!cx.StepStatus}</td>
            <td>{!cx.Comments}</td>
            <td>{!cx.Actor.Signature__c}</td>
            
            </tr>
        </apex:repeat> 
        </table>

1 Answer 1

0

Actor is a Name object, meaning it points to multiple types of records, and so you can't access custom fields for any given object directly. You'll need a custom extension to query the user records, which you can do:

<td>{!userMap[cx.ActorId].Signature__c}</td>

The map would look like:

public Map<Id, User> userMap { get; set; }
Material_Request__c matReq;

//Constructor
public MyClass(ApexPages.StandardController controller) {
  userMap = new Map<Id, User>();
  matReq = (Material_Request__c)controller.getRecord();
  for(ProcessStep step: matReq.ProcessSteps) {
    userMap.put(step.ActorId, new User(Signature__c=null));
  }
  userMap.putAll([SELECT Signature__c FROM User WHERE Id = :userMap.keySet()]);
}

Your page will use the extension:

<apex:page standardController="Material_Request__c" extensions="MyClass">

You must log in to answer this question.

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