• Sky1990
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 7
    Replies
Hi,

I have a button in a visualforcepage which is an inline visualforce page embedded in a standard page layout.

On the button click i just want to refresh the visualforce page not the entire standard page.

How can i do it.

Thanks,
Hi,

When ever a CaseMilestone is updated, I want to Insert/Update the Milestone data into a Custom Object.

As far as i know we cannot write a Trigger on CaseMilestone object.

Please suggest some solution to acheive this.

Thanks
Hi ,  I am not able to display some fields on VF Page when using Apex Controller.

I have 2 object
1. Case
2. Case Dummy

I store Case Id in my Case dummy to be able to relate between them.

Below is my Code:
 VF Page:
<apex:page standardController="Case_Proxy__c" extensions="CaseMilestoneUtils">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection columns="1" >
                <apex:pageblockTable value="{!CaseMilestones}" var="milestone">
                    <apex:column headerValue="Milestone Id" value="{!milestone.Id}"/>
                    <apex:column headerValue="Completion Date" value="{!milestone.CompletionDate}"/>
                    <apex:column headerValue="Completed" value="{!milestone.IsCompleted}"/>
                    <apex:column headervalue="Action" >                    
                            <apex:commandButton value="Mark As Complete" rendered="{!IF(milestone.IsCompleted == true,false,true)}" action="{!markMilestoneComplete}" reRender="hiddenBlock" >
                                <apex:param name="milestoneID" value="{!milestone.Id}" assignTo="{!milestoneID}" />
                            </apex:commandButton> 
                    </apex:column>                    
                </apex:pageblockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock id="hiddenBlock" rendered="false"></apex:pageBlock>
    </apex:form>
</apex:page>

Apex Code:
public without sharing class CaseMilestoneUtils{

    public CaseMilestoneUtils(ApexPages.StandardController controller) {
        stdCtrl=controller;
        refreshPage=false;
    }

    public List<CaseMilestone> milestones = null;
    public string Case_Id = null;
    public string milestoneID {get; set{milestoneID = value;}}
    public ApexPages.StandardController stdCtrl {get; set;}
    public Boolean refreshPage {get; set;}
         
    // Fetch the Id for the case Lite Records opened
    public string Case_Lite_Id = ApexPages.CurrentPage().getparameters().get('id');

    // Fetch the Case Id from the case_Proxy object based on the Case Lite Id
    public List<Case_Proxy__c> CaseProxy = [SELECT Case__c FROM Case_Proxy__c WHERE Id =: Case_Lite_Id LIMIT 1];

    // Displays all Milestones related to a Case 
    public List<CaseMilestone> getCaseMilestones(){
        if(CaseProxy.size() != 0){
            for(Case_Proxy__c Proxy : CaseProxy){
                Case_Id = Proxy.Case__c;
            }
            if(milestones == null) milestones = [SELECT Id, CompletionDate, IsCompleted FROM CaseMilestone WHERE CaseId =: Case_Id];
            return milestones;
        }
        return null;
    }
    
    // Method to Update the Case Milestone as Completed
    // It sets a particuler milestone to completed which is selected to be set to IsComplete
    public PageReference markMilestoneComplete(){
    
        if(milestoneID != null){
            CaseMilestone milestone = [SELECT Id,CompletionDate,IsCompleted FROM CaseMilestone WHERE Id  =: milestoneID LIMIT 1];
                        
            if(milestone.IsCompleted != true){
                milestone.CompletionDate = DateTime.now();        
                update milestone;
            }   
            refreshPage=true;
            stdCtrl.save();     
        }
        
        PageReference pageRef = new PageReference('/apex/ViewPageMilestones');
        pageRef.setRedirect(true);
        return pageRef;
    }
}

When I run the above code as an Admin Profile i am able to see the Columns and Data on VF page. But when i view it as a specific User with different profile i can't see the colums and data, i only see the "mark as complete " button column with a button for each record,not the rest of the columns.

Please suggest what might be going wrong. 
Hi,

I have a button in a visualforcepage which is an inline visualforce page embedded in a standard page layout.

On the button click i just want to refresh the visualforce page not the entire standard page.

How can i do it.

Thanks,
Hi,

When ever a CaseMilestone is updated, I want to Insert/Update the Milestone data into a Custom Object.

As far as i know we cannot write a Trigger on CaseMilestone object.

Please suggest some solution to acheive this.

Thanks
Hi ,  I am not able to display some fields on VF Page when using Apex Controller.

I have 2 object
1. Case
2. Case Dummy

I store Case Id in my Case dummy to be able to relate between them.

Below is my Code:
 VF Page:
<apex:page standardController="Case_Proxy__c" extensions="CaseMilestoneUtils">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection columns="1" >
                <apex:pageblockTable value="{!CaseMilestones}" var="milestone">
                    <apex:column headerValue="Milestone Id" value="{!milestone.Id}"/>
                    <apex:column headerValue="Completion Date" value="{!milestone.CompletionDate}"/>
                    <apex:column headerValue="Completed" value="{!milestone.IsCompleted}"/>
                    <apex:column headervalue="Action" >                    
                            <apex:commandButton value="Mark As Complete" rendered="{!IF(milestone.IsCompleted == true,false,true)}" action="{!markMilestoneComplete}" reRender="hiddenBlock" >
                                <apex:param name="milestoneID" value="{!milestone.Id}" assignTo="{!milestoneID}" />
                            </apex:commandButton> 
                    </apex:column>                    
                </apex:pageblockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock id="hiddenBlock" rendered="false"></apex:pageBlock>
    </apex:form>
</apex:page>

Apex Code:
public without sharing class CaseMilestoneUtils{

    public CaseMilestoneUtils(ApexPages.StandardController controller) {
        stdCtrl=controller;
        refreshPage=false;
    }

    public List<CaseMilestone> milestones = null;
    public string Case_Id = null;
    public string milestoneID {get; set{milestoneID = value;}}
    public ApexPages.StandardController stdCtrl {get; set;}
    public Boolean refreshPage {get; set;}
         
    // Fetch the Id for the case Lite Records opened
    public string Case_Lite_Id = ApexPages.CurrentPage().getparameters().get('id');

    // Fetch the Case Id from the case_Proxy object based on the Case Lite Id
    public List<Case_Proxy__c> CaseProxy = [SELECT Case__c FROM Case_Proxy__c WHERE Id =: Case_Lite_Id LIMIT 1];

    // Displays all Milestones related to a Case 
    public List<CaseMilestone> getCaseMilestones(){
        if(CaseProxy.size() != 0){
            for(Case_Proxy__c Proxy : CaseProxy){
                Case_Id = Proxy.Case__c;
            }
            if(milestones == null) milestones = [SELECT Id, CompletionDate, IsCompleted FROM CaseMilestone WHERE CaseId =: Case_Id];
            return milestones;
        }
        return null;
    }
    
    // Method to Update the Case Milestone as Completed
    // It sets a particuler milestone to completed which is selected to be set to IsComplete
    public PageReference markMilestoneComplete(){
    
        if(milestoneID != null){
            CaseMilestone milestone = [SELECT Id,CompletionDate,IsCompleted FROM CaseMilestone WHERE Id  =: milestoneID LIMIT 1];
                        
            if(milestone.IsCompleted != true){
                milestone.CompletionDate = DateTime.now();        
                update milestone;
            }   
            refreshPage=true;
            stdCtrl.save();     
        }
        
        PageReference pageRef = new PageReference('/apex/ViewPageMilestones');
        pageRef.setRedirect(true);
        return pageRef;
    }
}

When I run the above code as an Admin Profile i am able to see the Columns and Data on VF page. But when i view it as a specific User with different profile i can't see the colums and data, i only see the "mark as complete " button column with a button for each record,not the rest of the columns.

Please suggest what might be going wrong.