• A9865
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies
I have a "Add new Task" Button that should be displayed in every row of my visual force table via apex:repeat. The button leads to a rendered output panel, where a new task can be generated. When hitting the button in the according line, the field "Related To" of the new task should already be prefilled with the WhoId of the custom object that is queried within the Apex:repeat of the table.

Thus, how would I pass on the item.Id within the Apex repeat to the controller?
 
<apex:form >
    <apex:pageblock >
    <apex:pageMessages />

        <apex:outputpanel rendered="{!generateTask==false}">
            <table class="list" border="0" cellpadding="0" cellspacing="0" id="maintable">
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Start Date</th>
                        <th>New Task</th>
                    </tr>
                </thead>

                <apex:outputPanel id="tableData">
                    <apex:repeat value="{!lstDevRequests_edit}"  var="item">
                        <tbody>
                            <tr>
                                <td>{!item.Name}</td>
                                <td><apex:outputText value="{0,date,MM/dd/yyyy}"> <apex:param value="{!item.Start_Date__c}" /> </apex:outputText></td>
                                <td><apex:commandButton action="{!generateTask}" value="New Task" id="newTaskButton"/></td>
                            </tr>
                        </tbody>
                    </apex:repeat>
                </apex:outputPanel>
            </table>
        </apex:outputpanel> 

        <apex:pageBlockSection title="Create New Task" columns="2" collapsible="false" rendered="{!generateTask==true}" >
            <apex:pageBlockSectionitem >
                    <apex:outputLabel value="Assigned To"/>
                    <apex:inputField value="{!insertnewTask.OwnerId}"/>
            </apex:pageBlockSectionitem>
            <apex:pageBlockSectionitem >
                    <apex:outputLabel value="Subject"/>
                    <apex:inputField value="{!insertnewTask.Subject}"/>
            </apex:pageBlockSectionitem>
            <apex:pageBlockSectionitem >
                    <apex:outputLabel value="Related To"/>
                    <apex:inputField value="{!insertnewTask.WhatId}"/>
            </apex:pageBlockSectionitem>         
        </apex:pageBlockSection>

    </apex:pageblock>
</apex:form>
 
public with sharing class tableRequests {
public List<Dev_Request__c> lstDevRequests_edit {get; set;}
public Task insertnewTask {get;set;}
public boolean generateTask {get;set;}



public tableRequests() {
    generateTask = false;
    lstDevRequests_edit = lstDevRequests_edit();
    insertnewTask = getnewTask();
}

public List<Dev_Request__c> lstDevRequests_edit() {
    if(lstDevRequests_edit == null)
        lstDevRequests_edit = [Select Id, Name, Assignee__c, Assignee__r.Name, Start_Date__c, Due_Date_QA__c, Estimated_Hours__c, Estimated_Completion_Date__c, Status__c, Overview__c, Parent_Dev_Request__c, (SELECT Id, WhatId, ActivityDAte, Owner.Name, Description, Status, Subject from Tasks) from Dev_Request__c];
    return lstDevRequests_edit;
}

public Task getnewTask() {
    Task newTask = new Task();
        newTask.WhatId = 'a0626000000EGH1AAO'; // This needs to be profiled with the corresponding item.Id
    return newTask;
}

public PageReference generateTask(){
    generateTask = true;
    return null;
}
}

Thank you for your help!
I have the problem that my editable table does not update when I hit the "save" button. I tried inline editing and normal editing, nothing would save. Although I referred to a standard controller, I prefer the solution with a custom controller.
 
<apex:page standardController="Dev_Request__c" extensions="tableDevRequest_edit">
    <apex:form >
        <apex:pageblock mode="inlineEdit"> 
            <apex:pageMessages />  
            <apex:pageBlockButtons > 
            <!--<apex:commandButton value="Save" action="{!saveTable}" id="saveButton" rendered="{!editTable==true}" immediate="true"/>-->
            <apex:commandButton value="Save" action="{!saveTable}" id="saveButton" immediate="true"/>
            <apex:commandButton id="cancelButton" value="Cancel"/> 
            </apex:pageBlockButtons>  

             <apex:pageblocktable value="{!lstDevRequest_edit}"  var="item">
                    <apex:column headerValue="Dev Request Name"><apex:actionRegion ><apex:outputField value="{!item.Name}"><apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" /></apex:outputField></apex:actionRegion></apex:column>
                    <apex:column headerValue="Id"><apex:outputField value="{!item.Id}"/></apex:column>
                    <apex:column headerValue="Status"><apex:inputField value="{!item.Status__c}"/></apex:column>
                    <apex:column headerValue="Start Date"><apex:inputField value="{!item.Start_Date__c}"/></apex:column>
                    <apex:column headerValue="Due Date QA"><apex:inputField value="{!item.Due_Date_QA__c}"/></apex:column>
                    <apex:column headerValue="Estimated Hours"><apex:inputField value="{!item.Estimated_Hours__c}"/></apex:column>
                    <apex:column headerValue="Assignee"><apex:inputField value="{!item.Assignee__c}"/></apex:column>
                    <apex:column headerValue="Overview"><apex:inputField value="{!item.Overview__c}"/></apex:column>
             </apex:pageblocktable>

        </apex:pageblock>
    </apex:form>
 
public with sharing class tableDevRequest_edit {

   public List<Dev_Request__c> lstDevRequest_edit {get;set;}

    public tableDevRequest_edit(ApexPages.StandardController controller) {
        lstDevRequest_edit = [Select Id, Name, Assignee__c, Assignee__r.Name, Start_Date__c, Due_Date_QA__c, Estimated_Hours__c, Estimated_Completion_Date__c, Status__c, Overview__c from Dev_Request__c];
    }

    public PageReference saveTable() {
        try {
            update lstDevRequest_edit;
        }   
        catch(Exception e){
            System.debug('Exception occurred '+String.valueOf(e));
        }
        return NULL;
    }     
}

Thank you for helping!
Within my Salesforce.com application, a user gets redirected to the SF organisation community when he opens a specific tab. So far the user needs to log in into the community once the browser tries to open the community url. 

I have tried to pass the parameters within the url with the SessionId, PortalId/CommunityId and the OrgId but I still got prompted to login. I constructed the link used in the Visualforce controller like:
"https://fullsand-...-portal.cs1.force.com/.../s/secur/frontdoor.jsp?sid=...0&orgId=...&portalId=..."

Furthermore I tried SSO, but that also would not help as also the SF login screen would appear which I want to suppress. I used the following to set up SSO:
  • Issuer = Salesforce.org domain
  • Entity ID = Community Link
  • Service Provider Initiated Request Binding = HTTP POST
When I use the SAML Validator, I get these messages:
  • Unable to parse the response
  • Premature end of file
  • Unable to map the subject to a Salesforce.com user
I read through all resources available on the net, but they seem not to have a direct answer to my question. So I would highly appreciate some help and support - thank you in advance!