• Marcio Fritsch
  • NEWBIE
  • 15 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 7
    Replies
Recently I have tested ApexPages.StandardSetController method and used .save method and worked fine. However I have changed to add new Calculated fields and tried to use .RecalculateFormulas() available for sobject and I faced a message error:
Unable to create/update fields: <sobject>. Please check the security settings of this field and verify that it is read/write for your profile or permission set.
I think there is nothing regarding to this above once I just took out the .save() method and just invoked the recalculateFormulas(). If I just take out the master_detail_field from my query, it works.
Code sample below:
...
ApexPages.StandardSetController([SELECT id, name, Master_detail_Field__c FROM sobject])
...
        for(sobject s: setRecords.getrecords()){
            s.recalculateFormulas();
        }
I am creating a component which uses ApexPages.StandardSetController implementation. I can only send a simple query, but I need to send a group by, and it does not work. I may have over than 2000 rows, in this case I cannot use OFFSET.
This component will not update nothing, just to list.
Is there any work around to avoid this message error?

Is there any way to create a formula field to Rollup summarize from other formula? Nowadays apparently to solve it we need to create a stored field on object, do a workflow rule and after all, create a rollup sommarize field over this field. Or simply do a trigger ( ugly option).
Recently I have tested ApexPages.StandardSetController method and used .save method and worked fine. However I have changed to add new Calculated fields and tried to use .RecalculateFormulas() available for sobject and I faced a message error:
Unable to create/update fields: <sobject>. Please check the security settings of this field and verify that it is read/write for your profile or permission set.
I think there is nothing regarding to this above once I just took out the .save() method and just invoked the recalculateFormulas(). If I just take out the master_detail_field from my query, it works.
Code sample below:
...
ApexPages.StandardSetController([SELECT id, name, Master_detail_Field__c FROM sobject])
...
        for(sobject s: setRecords.getrecords()){
            s.recalculateFormulas();
        }
Hi All,

Is there anyway to force an object to recalculate it's formula fields, either through standard or extended controllers in visualforce page(Mostly using action:suppot).
While googling i found in Winter 16 release recalculateFormulas()  method is introduced.. But i dont know how to use it. Has anybody used this method.

Regards
I am creating a component which uses ApexPages.StandardSetController implementation. I can only send a simple query, but I need to send a group by, and it does not work. I may have over than 2000 rows, in this case I cannot use OFFSET.
This component will not update nothing, just to list.
Is there any work around to avoid this message error?

Is there any way to create a formula field to Rollup summarize from other formula? Nowadays apparently to solve it we need to create a stored field on object, do a workflow rule and after all, create a rollup sommarize field over this field. Or simply do a trigger ( ugly option).
Hello,

I am fairly new to apex and triggers, and I am having a hard time getting this particular trigger to do what I need it too.  I have looked over it several times and can't understand why it isn't working as I expect.  Any help is greatly appreciated!!

trigger isNewLeadCreated on Campaign_Influence__c (before insert) {
    for(Campaign_Influence__c CI: Trigger.new) {
        if(CI.LeadID__c != null) {
          List<Campaign_Influence__c> siblings = [Select id, new_lead_created__c, campaign_add_date__c from campaign_influence__c where LeadID__c = :CI.LeadID__c order by new_lead_created__c desc];
          List<Lead> parent = [Select id, SR_date_created__c from Lead where id = :CI.LeadID__c];        
        
        
        //If campaign is first campaign, not of the 3 types, not a list, and not setter contact without set.....True
        if(siblings.size() == 0 
            && (CI.campaign__r.type != 'List Upload' 
                || CI.campaign__r.type != 'Other' 
                || CI.campaign__r.type != 'Pricing')
            && CI.campaign__r.List__c != true
            && CI.campaign__r.ADR_Set__c != true ) {
        CI.new_lead_created__c = true;
        }
        
        //If campaign is not first campaign, new lead never checked on other campaigns, not of the 3 types, not a list, and not setter contact without set.....True
        if(siblings.size() > 0
            && Siblings[0].new_lead_created__c != true
            && (CI.campaign__r.type != 'List Upload' 
                || CI.campaign__r.type != 'Other' 
                || CI.campaign__r.type != 'Pricing')
            && CI.campaign__r.List__c != true
            && CI.campaign__r.ADR_Set__c != true ){
        CI.new_lead_created__c = true;
        }    
        
        if(siblings.size() > 0
            && Siblings[0].new_lead_created__c == true
            && CI.campaign__r.type == 'Cold Call') {
        CI.new_lead_created__c = true;
        Siblings[0].new_lead_created__c = false;
        Update Siblings[0];
        }               
}
}
}


  • August 15, 2014
  • Like
  • 0
Hey there,

I have a visualforce page with different Jquery functions. One is for highlighting rows and the other is for fixing a header whilst scrolling. For some reason, when implimenting the code in bold, it prevents me from navigating between tabs and even if I remove two of the four scripts....it will still not fix the header like it does in the second example. please help

Tabbed VF page (navigation/fixed header, highlihgting not working)

<apex:page standardController="Office__c"  showHeader="true"
tabStyle="Office__c"  >
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"/>
<apex:stylesheet value="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/ui-lightness/jquery-ui.css"/>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
    <script src="{!URLFOR($Resource.jquery_vfFloatingHeaders)}"></script>


<script>
$j = jQuery.noConflict();
function highlightElem(elem){
$j(elem).parent().parent().parent().find('tr').removeClass('ui-state-highlight');
$j(elem).parent().parent().addClass('ui-state-highlight');
}
</script>

<style>
.activeTab {background-color: #892034; color:White;
background-image:none}
.inactiveTab { background-color: #00204E; color:white;
background-image:none}
</style>

<style>
input[name=newNote] {
    display: none;
}
input[name=attachFile] {
    display: none;
}
</style>

<style>
        .tableContainer
        {
            height:70px;
            width: 100%;
            overflow: auto;
        }      
        .floatingStyle
        {
            position:relative;
        }
    </style>
<script>
    $(document).ready(function() {
        $('.floatingHeaderTable').vfFloatingHeaders();
    });
    </script> 
  



<apex:tabPanel switchType="client" value="{!BLANKVALUE($CurrentPage.parameters.tab,'Offdetails')}"
id="OfficeTabPanel" tabClass="activeTab"
inactiveTabClass="inactiveTab">
<apex:tab label="Details" name="Offdetails" id="tabdetails" >
<apex:detail inlineEdit="True" relatedList="true" title="true"/>
</apex:tab>


<apex:tab label="Office Commissions" rendered="{!$ObjectType.Office_Commission__c.Accessible}" name="Office Commissions" id="tabOfficeCommissions" >
<apex:pageBlock title="Office Commissions" >
<apex:form >
<apex:outputPanel styleClass="tableContainer" layout="block">
<apex:pageBlockTable value="{!Office__c.Office_Commissions__r}" var="OffCom" styleclass="floatingHeaderTable">
<apex:column headerValue="Office Commissions" >
<apex:commandLink rerender="OffComdetails" oncomplete="highlightElem(this);"> {!OffCom.Name}
<apex:param name="OffComid" value="{!OffCom.id}"/>
</apex:commandLink>
</apex:column>
<apex:column value="{!OffCom.Upfront_Bonus_Average__c}"/>
<apex:column value="{!OffCom.Ongoing_Bonus_Average__c}"/>

<apex:column value="{!OffCom.Commission_Period_Start__c}"/>
<apex:column value="{!OffCom.Commission_Period_End__c}"/>
</apex:pageBlockTable>
</apex:outputPanel>
</apex:form>
</apex:pageBlock>
<apex:outputPanel id="OffComdetails">
<apex:detail subject="{!$CurrentPage.parameters.OffComid}" relatedList="False" inlineEdit="True" title="false"/>
</apex:outputPanel>
</apex:tab>


Test VF page - fixed header working

<apex:page standardController="Office__c"  >

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
    <script src="{!URLFOR($Resource.jquery_vfFloatingHeaders)}"></script>
   
<style>
        .tableContainer
        {
            height:70px;
            width: 100%;
            overflow: auto;
        }      
        .floatingStyle
        {
            position:relative;
        }
    </style>

    <script>
    $(document).ready(function() {
        $('.floatingHeaderTable').vfFloatingHeaders();
    });
    </script>  

<apex:pageBlock title="Office Commissions" >
<apex:form >
<apex:outputPanel styleClass="tableContainer" layout="block">
<apex:pageBlockTable value="{!Office__c.Office_Commissions__r}" var="OffCom" styleclass="floatingHeaderTable">
<apex:column headerValue="Office Commissions" >
<apex:commandLink rerender="OffComdetails" > {!OffCom.Name}
<apex:param name="OffComid" value="{!OffCom.id}"/>
</apex:commandLink>
</apex:column>
<apex:column value="{!OffCom.Upfront_Bonus_Average__c}"/>
<apex:column value="{!OffCom.Ongoing_Bonus_Average__c}"/>

<apex:column value="{!OffCom.Commission_Period_Start__c}"/>
<apex:column value="{!OffCom.Commission_Period_End__c}"/>
</apex:pageBlockTable>
</apex:outputPanel>
</apex:form>
</apex:pageBlock>
<apex:outputPanel id="OffComdetails">
<apex:detail subject="{!$CurrentPage.parameters.OffComid}" relatedList="False" inlineEdit="True" title="false"/>
</apex:outputPanel>

</apex:page>