• SamirKhan
  • NEWBIE
  • 5 Points
  • Member since 2015
  • IBM

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 5
    Replies
I have created a VF page where in I am displaying some rows in a Table.
What i am trying to achieve is - there is one row named "Status" in the table.Status can have 3 values - RED , GREEN , GREY.
How can i color the row depending upon the value in the status field.
Below is my VF Page
 
<apex:page controller="AccountSummaryReportController" action="{!loadKeyAccounts}"  >


    
    <style>
             
             body .bPageBlock .pbBody .grey .pbSubheader{
                background-color:#c0c0c0;
            }
            body .bPageBlock .pbBody .grey .pbSubheader h3{
                color:#000;
           
                
      .greenColour {color:green;}
      .redColour {color:red;}
      .greyColour {color:grey;}  
            
        </style>
    <apex:sectionHeader title="Account Summary Report as of : {!TODAY()}"  description="This Report Shows Accounts modified in last 31 days"/>
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton action="{!renderAsPdf}" value="Save as Pdf"/>
            </apex:pageBlockButtons>
            <apex:repeat value="{!objectMap }" var="ProgNameKey" >
                <apex:pageBlock title="{!ProgNameKey}" id="c">
                    <apex:repeat value="{!objectMap [ProgNameKey]}" var="PlanNameKey" >
                        <apex:outputPanel styleClass="grey" layout="block">
                            <apex:pageBlockSection title="{!PlanNameKey}" columns="1" >
                                <apex:pageBlockTable value="{!objectMap [ProgNameKey][PlanNameKey]}" var="lstGrnRate"  border="1" columnsWidth="20%,10%,70%">
                                    <apex:column value="{!lstGrnRate.Account__r.Name}"/>
									
                                    
                                    <apex:column value="{!lstGrnRate.Status__c }" 
                                      styleClass = "{! If(lstGrnRate.Status__c=='RED' ,'redColour',
                                                      If(lstGrnRate.Status__c=='Green','greenColour', 'greyColour')) }" /> 
													  
													  
          
          
                                    <apex:column value="{!lstGrnRate.Account_Summary__c}"/>
                                </apex:pageBlockTable>
                            </apex:pageBlocksection>
                        </apex:outputPanel>
                    </apex:repeat>
                </apex:pageBlock>
            </apex:repeat>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
I have two custom Object , Salesorder and SalesYear.SalesYear has two records - 2015 and 2016.SalesOrder Has a lookup to Salesyear.What i am trying to achieve is when i click on new salesorder , it should auto populate a value for salesyear i.r 2016
For this i have written a trigger, and it doesnot works for some reason which i am not aware of.
Can some one guide me in achieving this?
 
trigger SalesOrderTrigger on gii__SalesOrder__c (before insert, before update) {



    Sales_year__c objSales_year = new Sales_year__c();
    objSales_year = [select id from Sales_year__c where name = '2016'];
    for(gii__SalesOrder__c objOrder : trigger.new){
        objOrder.Sales_Year__c= objSales_year.id ;
    }
}

 
We have a running functionality like there is a VF detail page and then there is an inline vf page which just contains couple of buttons. When we click on any button , new vf page opens in a new window.

Now what we want to achieve is that when we click a button on inline vf page , instead of opening a vf page in new window,we want to open that same window in place of the parent page.

Is this possible. Can some one guide me to a small demo if possible?

my inline vf page
<apex:page StandardController="gii__SalesOrder__c" extensions="giic_SalesOrderDetailButtonsCtrl">
        <apex:includeScript value="{!URLFOR($Resource.Datatable,'datatable/js/jquery-1.11.1.min.js')}"/>
        <apex:outputPanel id="scriptPanel">
            <script>
            <apex:repeat value="{!jsFunctionMap}" var="funcTemp">  
                {!jsFunctionMap[funcTemp]}
            </apex:repeat>
            $j = jQuery.noConflict();

            // Render table only when rest of document is loaded.
            $j(document).ready(function() { 
                tempFunction();
            });
            </script>
        </apex:outputPanel>
    <apex:form id="soBtnForm" styleClass="soBtnFormCls">
        <apex:actionFunction name="tempFunction" action="{!tempFunction}" rerender="scriptPanel"/>
        
        <apex:dynamicComponent componentValue="{!dynamicForm}"/>
         

        <apex:repeat value="{!jsFunctionMap}" var="funcTemp">  
           <apex:commandButton onclick="{!funcTemp}return false;" value="Say Hi"/>
        </apex:repeat>


    </apex:form>

</apex:page>

My controller
public class giic_SalesOrderDetailButtonsCtrl {

    public gii__SalesOrder__c salesOrder{get;set;}

    public Map<String, String> buttonsWithURLMap{get;set;}

    public Map<String, String> jsFunctionMap {get;set;}
    public String tempURL;

    //public List<Component.Apex.CommandButton> weblinks{get;set;}
    //public Component.Apex.CommandButton weblink{get;set;}

    public giic_SalesOrderDetailButtonsCtrl(ApexPages.StandardController controller) {
        salesOrder = (gii__SalesOrder__c) controller.getRecord();
        //weblinks = new List<Component.Apex.CommandButton>();
        buttonsWithURLMap = new Map<String, String>();
        jsFunctionMap  = new Map<String, String>();
        jsFunctionMap.put('tempFunc();','function tempFunc(){}');

        HttpRequest req = new HttpRequest();
        req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
        req.setHeader('Content-Type', 'application/json');
        req.setEndpoint('https://cs1.salesforce.com/services/data/v34.0/tooling/query/?q=SELECT+Id,+Description,+DisplayType,+LinkType,+FullName,+Metadata,+Name,+NamespacePrefix,+OpenType,+Position,ShowsLocation,+Url,+Width+FROM+WebLink+WHERE+EntityDefinition.QualifiedAPiName=\'gii__SalesOrder__c\'');
        req.setMethod('GET');

        Http http = new Http();
        Integer count = 1;
        String funcName = 'tempFunc';
        HttpResponse res = http.send(req);
        WebLinkList listButtons = (WebLinkList)JSON.deserialize(res.getBody(), WebLinkList.class); 
        for(WebLinkWrapper button: listButtons.records){
            if(button.LinkType == 'javascript'){
                jsFunctionMap.put(funcName+count+'();','function '+funcName+count+'(){'+button.Url+'}');
                count++;
            }
        }
    }

    public Component.Apex.PageBlock getDynamicForm() {
        Component.Apex.PageBlock dynPageBlock = new Component.Apex.PageBlock();

        HttpRequest req = new HttpRequest();
        req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
        req.setHeader('Content-Type', 'application/json');
        req.setEndpoint('https://cs1.salesforce.com/services/data/v34.0/tooling/query/?q=SELECT+Id,+Description,+DisplayType,+LinkType,+FullName,+Metadata,+Name,+NamespacePrefix,+OpenType,+Position,ShowsLocation,+Url,+Width+FROM+WebLink+WHERE+EntityDefinition.QualifiedAPiName=\'gii__SalesOrder__c\'');
        req.setMethod('GET');

        Http http = new Http();
        Integer count =1;
        String funcName = 'tempFunc';
        HttpResponse res = http.send(req);
        List<Component.Apex.CommandButton> weblinks = new List<Component.Apex.CommandButton>();
        WebLinkList listButtons = (WebLinkList)JSON.deserialize(res.getBody(), WebLinkList.class); 
        for(WebLinkWrapper button: listButtons.records){
            if(button.LinkType == 'url' || button.LinkType == 'page'){
                String url = button.Url;
                tempURL = url;
                buttonsWithURLMap.put(button.Metadata.masterLabel, url);
                Component.Apex.CommandButton weblink = new Component.Apex.CommandButton();
                weblink.value = button.Metadata.masterLabel;
                String Trul = '\''+'/servlet/servlet.Integration?scontrolCaching=1&lid='+button.id+'&eid='+salesOrder.id+'&ic=1'+'\'';
                weblink.onclick='openIntegration('+Trul+', "_self")';
                //weblink.onclick='navigateToUrl('+Trul+', \'DETAIL\');';
               // weblink.onclick='window.open('+Trul+',"_system")';

                weblinks.add(weblink);
            }
            if(button.LinkType == 'javascript'){
                Component.Apex.CommandButton weblink = new Component.Apex.CommandButton();
                weblink.value = button.Metadata.masterLabel;
                String tempId = String.valueOf(button.id).subString(0,15);
                weblink.onclick= funcName+count+'();return false';
                count++;
                weblinks.add(weblink);
            }
        }

        for(Component.Apex.CommandButton weblink: weblinks){
            dynPageBlock.childComponents.add(weblink);
        }
        return dynPageBlock;
    }

    public void tempFunction(){

    }

    public PageReference updateOrder(){
        PageReference pf = new PageReference('/apex/giic_checkValidationOrder?id='+salesOrder.gii__Account__c+'&button=order&soid='+salesOrder.id);
        return pf;
    }

    public class WebLinkList{
        public List<WebLinkWrapper> records{get;set;}
    }
    public class WebLinkWrapper{
        public String LinkType{get;set;}
        public String Name{get;set;}
        public String Id{get;set;}
        public String Url{get;set;}
        public WebLinkMetadata Metadata{get;set;}
    }

    public class WebLinkMetadata{
        public String masterLabel{get;set;}
    }
}

 
I have a page made in bootstrap and i want to merge that page in visualforce.

Is it possible..Can someone please help me out here and let me know hou this can be done

Thanks in Advance, Samir
Is there any way to Chatter Feed Tracking programatically for a field which is long / rich datatype in salesforce.com?

I tried to do this using salesforce standard way but was not able to get the old and new value in chatter using set history tracking button.

But for normal fields , i am getting new/old value in chatter.

I came to know that the chatter standard way doesnot give old and new value for fields with characters more than 256 .

Can some let me know how this can be achieved.

Best regards, Samir
I want to track a long field on chatter.But i came to know the standard functionality of salesforce that rich / long field's old and new value are not posted.

I hope this can be achieved using apex .

Could you please guide me how can i achieve this.

Thanks in advance and a very happy weekend Samir
I have written a script to open a page i new tab on click of a command button.But I get the following error : window.open is not a function()

i have not created any variable named "Open" which may have over written the open() function.

My script is like this
 


My command buton is :


 
I have one radio button and one inputfield..I am trying to achieve something like.if i click on the radio button , the input field should get active and user should be able to enter the value..If the radio button is not selected ..the field should be availabe but it should be disabled.

I have written something like below..but its not working

 
<input onclick ="document.getelementbyid('datepurchased').disabled =true;" type = "radio" name = "abc"></input>   
<apex:inputField id="datepurchased" value="{!lstRMA[0].Date_Purchased__c}"/>

 
LastName and Company fields no nulls allowed, but I not want to overwrite if the recode is existing when upsert data, how to handle it?

list<Lead> objLead = new List<Lead>();
for (Integer i = 0; i < OpenIDList.size(); i++)
        {
            objLead.add(
                New Lead(
                    LastName = 'LName',
                    company = 'Company A',
                    OpenID__c = '000001',
                  )
            );

        }

        try {
            upsert objLead OpenID__c;
        } catch (DmlException e) {

        }
Can anyone suggest where can I get scenario based questions for interviews of different SFDC concepts ?
Is there any way to Chatter Feed Tracking programatically for a field which is long / rich datatype in salesforce.com?

I tried to do this using salesforce standard way but was not able to get the old and new value in chatter using set history tracking button.

But for normal fields , i am getting new/old value in chatter.

I came to know that the chatter standard way doesnot give old and new value for fields with characters more than 256 .

Can some let me know how this can be achieved.

Best regards, Samir
I have one radio button and one inputfield..I am trying to achieve something like.if i click on the radio button , the input field should get active and user should be able to enter the value..If the radio button is not selected ..the field should be availabe but it should be disabled.

I have written something like below..but its not working

 
<input onclick ="document.getelementbyid('datepurchased').disabled =true;" type = "radio" name = "abc"></input>   
<apex:inputField id="datepurchased" value="{!lstRMA[0].Date_Purchased__c}"/>