• ministe2003
  • NEWBIE
  • 253 Points
  • Member since 2009

  • Chatter
    Feed
  • 8
    Best Answers
  • 2
    Likes Received
  • 1
    Likes Given
  • 18
    Questions
  • 116
    Replies

Hi,

 

I have my accounts related on a way that one parent Account is pointed by its daughters with the field ParentId.

 

I need to do a trigger that when the parent account is modified in the field Recovery_actions__C(is a checkfield), this change has to go to the daughters accounts.

 

This is my trigger:

 

trigger UpdateCierrePorRecobro on Account (beforeupdate) {

 

Set<Id> addAccountsActivate = newSet<Id>();

Set<Id> addAccountsDeactivate = newSet<Id>();

 

//Aislo los id's

 

for(integer i=0;i<Trigger.new.size();i++){

//If the value has changed add to the list

if ((Trigger.new[i].Recovery_Actions__c!=Trigger.old[i].Recovery_Actions__c)) { 

if (trigger.new[i].recovery_actions__c){//changed to true

addAccountsActivate.add(Trigger.new[i].id);

}

else{//changed to false

addAccountsDeactivate.add(Trigger.new[i].id);

}

}

}

if(addAccountsActivate.size()>0){

 

//create a list of ids with the daughter ids of the main account

//????????????????????????????????????????

List<id> listaToTrue=newList<id>();

listaParaActivar.add([select id fromAccountwhereParentId in:addAccountsActivate]);

//????????????????????????????????????????????

 

Accountacc;

 

//and update the value

for(integer j=0;j<listaToTrue.size();j++){

acc.id=listaParaActivar[j];

acc.Reacovery_Actions__c=1;

updateacc;

}

}

 

}

 

 

---------------------------------------

 

I have the problem in the part where I query in order to get the ids of the daughter accounts, I dont know how to get that list of ids.

 

Anyone could help here?

 

Thanks,

Antonio

Hi Guys,

 

I have a developed a visualforce page which is when opened in an Internet Explorer (v 8) shows an error in the status bar as 'Object required'. It shows the line number as well.

I have observed this typical behavior of the page with Internet Explorer only.There are issues with the mozilla firefox.

(v 3.6.20 )


Also a small question regarding this behavior - Does VF pages behave differently with different browsers ?

 

Please Suggest.

 

 Thanks and Regards,

 

gk_myguru

Hi I keep getting this error:

Constructor not defined: [ProductBreakdown.OpportunityTotal].<Constructor>(SOBJECT:OpportunityLineItem)

What is wrong with my code?

 

   public List<OpportunityTotal> getOpportunityTotals() {
        List<OpportunityTotal> OpportunityTotals = new List<OpportunityTotal>();
        for(OpportunityLineItem o:[SELECT Id,  
                            TotalPrice, Product_Name__c, Opportunity.Id, 
                            Opportunity.Name, Opportunity.StageName,
                            Opportunity.Accountid, Opportunity.Amount 
                            FROM OpportunityLineItem Where 
                            Opportunity.StageName='Closed Won' And 
                            Opportunity.Account.id='001Q000000Js7pP' 
                            ])
            {
                OpportunityTotals.add(new OpportunityTotal(o));
            }
        return sortOpportunityTotals(OpportunityTotals);
    }

 Thanks

 

We have multi-currency feture enabled.

 


We have several custom objects for documents like sales order, sales quote, ap invoice ,where values  are stored in the local exhange rate.  GBP, EUR, CHF etc. and the corporate currency is set as USD.
 
I need to be able to record an amount (in a new field) in USD
 
Does anyone have a solution to get values for a currency feild in its curporate currency value.

 

I have trieid using convertCurrency in the select statements but it returns the values in user's currency.

 

I want to know, how do we get the values in corporate currency for any  currency field value.

 

Thanks


Hi Dev,

 

I am creating a VFPage which creates a contact. I am using Standard controller and inputfield for that.

 

Now the Problem is I am not getting the salutation inside the FirstName. How to do it?

 

Example:    FirstName : [  [\/]] [                    ]

       |             |

                                   Salutation    FirstName

 

 

Regards,

shra1

 

I am using standardList controller for a custom object where the list entries are referred to as 'entry'

When you click on an individual entry (as a commandLink) the <apex:detail> area shows the standard detail for the object ie name, owner, modified, custom fields, etc.

Much like "Implementing Partial Page Updates with Command Links and Buttons" in the VF Dev Guide

 

How do I reference the individual fields for the entry in the detail?  

 

For example, how would I show only the name or a customField__C in the detail?  Is there another VF component I could use that will take an url+ object id as an argument to use in a redirect?

 

 Here's my detail area on the VF page - takes the url of the selected object id as 'subject' and displays all of the fields in the detail tag.

 

 

            <apex:outputPanel id="sigDetail">
                 <apex:detail subject="{!$CurrentPage.parameters.eid}" relatedList="false" title="false"/>   
             </apex:outputPanel> 
            
 I thought I could say something like {!$CurrentPage.parameters.eid.name} or {!$CurrentPage.parameters.eid.customField__c} but it doesn't seem to work that way.  What I'm actually trying to do involves much more than simply displaying a single field, but I do need to isolate the fields individually in order to get started.
Any help would be much appreciated.

 

Hi, simple question I hope, although I'm struggling with it!

I have a file I want to make available for download within a community.  It's a csv template that is only useful for this particular community.  What is the best way to make this file available for users to download?

I've tried adding the file as a Document under Assets in Site.com Studio but am unable to figure out what link to use to access it.  "/filename" doesn't work.

I can upload it in Salesforce as a File and create a public link, but I'd rather not have to use a full, hardcoded url if I can avoid it.

How have you got around this?
I have a lightning-datatable web component which is happily displaying data.  I have written an onsort function which is performing the sort correctly in the controller but is not rerendering the display of the table so nothing appears to change.

I know the rows are being sorted because the rows have view and edit actions and clicking these performs the action against the correctly sorted row, even if it doesn't match what's being displayed.  It's as if I need to manually trigger some kind of refresh to cause the data on the screen to be updated to match the data in the controller, but the data is @api decorated so it should be doing it automatically, as I understand it.

There's not much out there about lightning web components, wondered if someone on here could offer a suggestion?
 
<template>
    <lightning-datatable data={tblData}
                         columns={columns}
                         hide-checkbox-column={hideCheckboxColumn}
                         sorted-by={sortedBy}
                         sorted-direction={sortedDirection}
                         key-field={keyField}
                         onsort={updateColumnSorting}
                         onrowaction={handleRowAction}
    >
    </lightning-datatable>
</template>
import { LightningElement, api, track} from 'lwc';
import { CurrentPageReference, NavigationMixin } from 'lightning/navigation';

export default class DatatableSortableWeb extends NavigationMixin(LightningElement) {
    @api tblData = [];
    @api columns;
    @api hideCheckboxColumn;
    @api sortedBy;
    @api sortedDirection;
    @api keyField;

    /*
    If user clicks a column header, sort using event params
    */
    updateColumnSorting(event) {
        var fieldName = event.detail.fieldName;
        var sortDirection = event.detail.sortDirection;

        // assign the latest attribute with the sorted column fieldName and sorted direction
        this.sortedBy = fieldName;
        this.sortedDirection = sortDirection;
        this.tblData = this.sortData(fieldName, sortDirection);
    }

    /*
    Sort table, ignoring case and treating empty cells as "zzz" so they come last when sorting ASC
    */
    sortData(fieldName, sortDirection) {
        var dataToSort = this.tblData;
        var reverse = sortDirection !== 'asc';
        //sorts the rows based on the column header that's clicked
        dataToSort.sort(this.sortBy(fieldName, reverse));
        return dataToSort;
    }

    sortBy(field, reverse, primer) {
        var key = primer ?
            function(x) {return primer(x.hasOwnProperty(field) ? (typeof x[field] === 'string' ? x[field].toLowerCase() : x[field]) : 'zzz')} :
            function(x) {return x.hasOwnProperty(field) ? (typeof x[field] === 'string' ? x[field].toLowerCase() : x[field]) : 'zzz'};

        //checks if the two rows should switch places
        reverse = !reverse ? 1 : -1;
        return function (a, b) {
            return a = key(a), b = key(b), reverse * ((a > b) - (b > a));
        }
    }


 

Hi all,

I'm using a StandardSetController to hold lots of records but through pagination, only display a few at a time in a pageblocktable.

It's holding cases.  If I run a query which populates the SSC with several thousand cases I'm getting the Maximum view state size limit (135KB) exceeded errors.  The pageSize is set to just 20, so why am I getting this issue?!  I thought the whole point of using a SSC was to get around this issue?  It seems that even though my page size is 20, the view state is holding EVERY record in the SSC, which is several thousand and causing this issue.

 

Why am I getting this error despite using pagination?

 

Thanks

Hi,

Since the Spring 11 update we've been having issues with Developer mode.  If we open a VF page, the developer mode strip opens at the bottom of the page but the page itself doesnt load and the screen goes white.  Several refreshes later and the page sometimes loads.

 

Noticed this in test before production was updated to spring.  Anyone else having this issue and is there any resolution (other than, obviously, turn off developer mode!)

Hello,

InlineEditing allows us to show and hide buttons during and after editing inline.  However buttons I want hidden by default are displayed.

 

For instance, I have several buttons I want to show by default and hide when editing, plus a Save and Cancel button that I want hidden unless told to display by inline editing.  But when the page loads all of these buttons are displayed.  How am I supposed to make Save and Cancel hidden on page load, surely I dont have to use JS or CSS for that, it must be part of the inline editing capability surely?!

 

 

MORE INFO: Im not using a standard controller everything in the page is handled in a class.  Clicking the Save button (which calls a save method which updates the database, as you'd expect) doesnt save any changes made in inline editing.

I'm starting to think that inline editing will only work with a Standard Controller...

Hi all,

I needed to do an ajax refresh on a single pageblocksection item, which is a required field.  As anyone who's used actionsupport or another ajax function in salesforce will know, they pretty much require your items to be wrapped in an output panel in order to work.

Now this is fine if you want to refresh an entire pageblocksection but if you want to refresh one field within a section, wrapping it in an output panel causes the field to lose formatting and there seems to be no way to retain it.

 

Using the wonderful FireBug I've managed to make my field refresh without the need for output panel so we can format the fields in a SalesForcey way.  Here is an example of a row with two columns, a field and label in each:

 

 

<div class="pbSubSection">
<table class="detailList" cellSpacing="0" cellPadding="0" border="0">
<tbody>
<tr>
<td class="labelCol first">
<label>Stage</label>
</td>
<td class="dataCol first">
<div class="requiredInput">
<div class="requiredBlock"></div>
<apex:inputfield value="{!opp.StageName}">
<apex:actionSupport action="{!stageToggle}" event="onchange" reRender="myBP"/>
</apex:inputfield>
</div>
</td>
<td class="labelCol first">
<label>Forecast Category</label>
</td>
<td class="dataCol first">
<div class="requiredInput">
<div class="requiredBlock"></div>
<apex:inputField value="{!opp.Forecast_Stage__c}" id="forcat">
<apex:actionSupport event="onchange" reRender="csd, rsnlst, rsnlstdtl" status="status1"/>
</apex:inputField>
<apex:actionstatus id="status1">
<apex:facet name="start">
<apex:image url="/img/loading24.gif" rendered="true"/>
</apex:facet>
</apex:actionstatus>
</div>
</td>
</tr>
</tbody>
</table>
</div>

 

This comes out as follows:

 

 

use <tr> to make multiple rows (in this example there is just one) and wrap your label and field up in separate <tr> tags.

 

You dont need to include the requiredfield or requiredblock div tags as I have, they just add the red bar to show the field is required.

Anyone wondering what the image is in the actionstatus, it's a nice spinny loading image which looks like this:

 

 

The important thing to notice is the class references which call the style class data from the salesforce css files.

Also, DO NOT wrap this inside apex:pageBlockSection> tags or you'll kill it!

 

I hope people might find this useful :)

 

Steven

 

Hi all,

Some of our users are getting insufficient privileges errors when creating an object but we cant find out why.

I have debugged on FINEST and get no error however what I do see is that when trying to query the Partner table, nothing happens.  No results, no errors, no exceptions - everything just stops.

 

This doesnt happen for me (admin) I see the results of the query.  For that matter, in this example there actually isnt a result but we catch the exception and deal with it and carry on through the method.

 

Here is the line of code where the debug log ends:

 

 

Partner ptnr = [SELECT AccountTo.Id, AccountTo.Type, Role FROM Partner WHERE IsPrimary = TRUE AND Opportunity.ID = :newOpp.Id LIMIT 1];

 

 

and this is the debug output for that line (289):

 

12:05:25.358 (325898000)|LIMIT_USAGE_FOR_NS|[289]|SCRIPT_STATEMENTS|57|200000
12:05:25.358 (325931000)|STATEMENT_EXECUTE|[289]|DeclareVar: SOBJECT:Partner ptnr
12:05:25.358 (325954000)|VARIABLE_SCOPE_BEGIN|[289]|ptnr|Partner|true
12:05:25.359 (326119000)|SYSTEM_MODE_EXIT|APEX_SHARING_HONORED

 

 

As you can see the code just stops and there is no logging of any issue or the query being run so I imagine there is a priviliges problem with the Partner object?  If so how can I get around this?

We never used to have this problem until we did a revamp of user profiles so it must be some profile issue.

 

Please can someone help as I cant see where we can modify access to a Partner object but this is causing us major problems!

 

Thanks so much.

Steven

Hi all,

Major problem.  We have overridden the opportunity new, view and edit controls and visualforced all opportunity view and edit pages.  In the visualforce I have added the [change] link next to the Record Type on the view page.

 

When I click the change link next to the record type and choose a type from the drop down then click continue, it takes me back to the view page (which I would expect) but the record type has not changed:

 


 

Also on another page I'm just using the detail tag (thereby not writing the [change] link manually) and it still doesnt work.  Seems to me the problem is caused because the Edit  function is overwritten with a visualforce page.  The record type change page is managed by a jsp page but it would seem the owner isnt actually changed here and somehow it is passed somewhere else once the Continue button is clicked but because we have overridden view and edit, whatever process that would normally handle the record type change is now no longer being called.

 

Seems strange that salesforce would give me the option to override these pages when it clearly leads to a problem of this kind, can anyone offer a suggsetion?

 

Thanks

Steven

Hi all,

I'm writing a custom component which is basically a select list with all the ajax refresh functionality built in, to save having to write a pageblock section item with an output panel in it, with a select list in that etc etc.

 

I have an ActionSupport within my component, like so:

 

 

<apex:component >

<apex:attribute name="fieldLabel" description="Output label text value."
type="String" required="true"/>
<apex:attribute name="fieldValue" description="The object field we are filling in."
type="String" required="true"/>
<apex:attribute name="SelectOptionsList" description="List of SelectOptions components."
type="String" required="true"/>
<apex:attribute name="actionPerformed" description="Action performed by the ActionSupport."
type="String" required="false"/>
<apex:attribute name="reRenderBlock" description="Section on the page to reRender"
type="String" required="true"/>

<apex:outputlabel value="{!fieldLabel}"/>
<apex:panelGroup >
<apex:selectList value="{!fieldValue}" size="1">
<apex:selectoptions value="{!SelectOptionsList}"/>
<apex:actionSupport action="{!actionPerformed}" event="onchange" reRender="{!reRenderBlock}" status="status1"/>
</apex:selectList>
<apex:actionstatus id="status1">
<apex:facet name="start">
<apex:image url="/img/loading24.gif" rendered="true"/>
</apex:facet>
</apex:actionstatus>
</apex:panelGroup>

</apex:component>

 

I want {!actionPerformed} to be the action that the ActionSupport runs but because I will be using this component in lots of places, it needs to be selected by the user by an attribute.  When I put the component in the page, like so:

 

 

<c:ajaxSelectList fieldLabel="Product Family" fieldValue="{!imrf.Product_Family__c}" selectOptionsList="{!ProdFamilyPicklist}"
                                    actionPerformed="{!updateFieldValues}" reRenderBlock="refreshMe" />

 

 

I get this error:

 

 

Error: Unknown property 'IMRFNewEditController.updateFieldValues'	
Quick Fix	Create Apex property 'IMRFNewEditController.updateFieldValues'
Quick Fix	Create Apex method 'IMRFNewEditController.getUpdateFieldValues'

 

 

The issue is that it thinks im passing through a property, not a method call.  The method is in the class, it is actually used here in the original full form of the selectlist, for example:

 

 

<apex:pageblocksectionItem >
                    <apex:outputlabel value="Product Family"/>
                    <apex:panelGroup >
                        <apex:selectList value="{!imrf.Product_Family__c}" size="1">
                            <apex:selectoptions value="{!ProdFamilyPicklist}"/>
                            <apex:actionSupport action="{!updateFieldValues}" event="onchange" reRender="refreshMe" status="status1"/>
                        </apex:selectList>
                        <apex:actionstatus id="status1">
                                <apex:facet name="start">
                                    <apex:image url="/img/loading24.gif" rendered="true"/>
                                </apex:facet>
                        </apex:actionstatus>
                    </apex:panelGroup>
                </apex:pageblocksectionItem>

 

How can I make the component attribute accept my method call?  Cant find any examples of this so maybe it just isnt possible, which would be disappointing!

 

Thanks

Steven

Hello,

I'm struggling to come up with an answer to this by myself so thought Id throw it out there.

 

Sometimes if a SOQL query returns no results it throws an exception, which can be caught and then the field populated differently, ie created.  However sometimes it doesn't throw an exception so I have to wrap my query in a try{catch} and then outside of that, also check to make sure the return isn't null so I can handle that too.

 

Is there a logical reason why it does this?  It's making my code unnecessarily long and at best, is just annoying!

 

Thanks for any replies

Steven

Hello

I've overridden the New page on Campaigns to render different things on a VF page depending on the RecordTypeID but I have a problem.

 

If a profile only has access to one campaign record type then the page doesnt render anything.

My PageBlocks are rendered based on recordtype, ie

 

rendered="{!Campaign.RecordTypeID = 'X'}"

 

 

This works fine for everyone except those who only have access to one record type.

Users who's profile only allows them to access one record type are never presented with the page to choose the campaign record type from a drop down, this seems to be the key - they are taken straight to the New page.

 

The controller seems to have no information in it (I've checked by debugging my apex) including the recordtypeid and this is causing no pageblocks to render.  The question is how can I tell in this situation which page to render?  SalesForce must know somehow what record type we're dealing with because it chooses the correct PageLayout in this situation, so how do i do it in apex/visualforce?

 

Thanks

 

Steven

Hi all,

I'm doing a simple if statement in my visualforce to display data in a column, choosing one of two fields if one is null (one will always be null out of the two).

 

this is what it looks like

 

<apex:column title="Certified For All" value="{!IF(ISNULL(CI.Certified_Installer_OLD__c),CI.New_Certified_Installer_Number__c, CI.Certified_Installer_OLD__c)}"  />

 But I get this error

 

 

Visualforce Error

Syntax error. Missing ')'

 I dont get it from the complier, just on the page.  The thing is, this works fine

 

 

<apex:column title="Certified For All" value="{!IF(1<2,1, 2)}"  />

So it cant be a brackets issue or that wouldnt work either.

 

 

 

Anyone got a clue what's wrong?  I'm querying the data so its not that.

 

Thanks!

 

Hi,

If an opportunity is not in the organisation's default currency, the amount is displayed in it's local currency and in the org's default in brackets next to it.

 

eg

 



How can I access this converted amount? I'm writing a custom big deal alert email and want the value in the subject to be in GBP regardless of the opportunty's currency.

 

Thanks!

Steven

Hi,

I'm doing a visualforce email and using a datatable to display a list of data.  I'm styling it with CSS which works fine in the preview but once I email myself the test, the css is not applied and I just see a standard datatable.  Anyone know if there's a way to fix this?

 

Here's the Visualforce and CSS:

 

<style type="text/css">
p,#Opportunity{
font-size:1.0em;
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
}
#Opportunity,#Opportunity td, #Opportunity th,.tableHead, .tRowOdd,.tRowEven
{
border-collapse:separate;
border-color:gray;
border-spacing:0px;
border-width:1px;
border-style:outset;
background-color: white;
font-size:0.9em;
}
#Opportunity td, #Opportunity th,.tableHead, .tRowOdd,.tRowEven
{
padding:3px;
border-style:inset;
-moz-border-radius:3px;
text-align:left;
}
.tRowEven
{
background-color:#FFF8DC;
}
#Opportunity th,.tableHead
{
background-color:#F7921E;
}
#Opportunity .OppName
{
text-align:center;
}
</style>

 

<apex:datatable styleClass="Opportunity" rowClasses="tRowOdd, tRowEven" headerClass="tableHead" value="{!relatedTo.OpportunityLineItems}" var="Oli" cellpadding="3" border="1">
  <apex:column >
    <apex:facet name="header">Product</apex:facet>
    {!Oli.PricebookEntry.Name}
  </apex:column>
  <apex:column >
    <apex:facet name="header">Product Code</apex:facet>
    {!Oli.PricebookEntry.ProductCode}
  </apex:column>  
  <apex:column >
    <apex:facet name="header">Quantity</apex:facet>
    {!Oli.Quantity}
  </apex:column>
  <apex:column >
    <apex:facet name="header">Sales Price</apex:facet>
    {!Oli.UnitPrice}
  </apex:column>
  <apex:column >
    <apex:facet name="header">Total Price</apex:facet>
    {!Oli.TotalPrice}
  </apex:column>
</apex:dataTable>

 

 

Thanks for any help.

 

Steven

 

Hi all,

Trying to allow users to create a case via sites on our intranet.  That isnt a problem, however I dont seem to be able to allow the user to create Attachments.

 

There's nothing in the user profile to allow access to Attachments that I can see but I'm getting Authorization errors when I try and insert an attachment.

 

Anyone know how I can do this?

 

Thanks

Steven

Hi all

I was having issues with too many SOQL queries in a trigger.  I'm trying to mass update opportunities which I think the limit of is 19, so I changed the code to work with a Batchable class.  Then I got too many concurrent batches errors.  So in my trigger, I query the AsyncApexJob object and only set batches to run when the queue is clear.

 

Now I'm back to having too many SOQL queries because I'm querying AsyncApexJob too often!  AAGH!!

 

Is there a way around this?

 

Regards

 

Steven

Hi all,

Writing some apex which converts an opportunity to another custom object of mine, and it acts upon a button press.  When it fails I want to display page messages to inform the user why it failed.  However, with it being a standard page I dont seem to be able to do it.  In a custom page obviously I'd just stick in the <apex:messages /> tag but with this being the standard Opportunity page, how can I display messages?

 

Thanks!

 

Steven

Hello,

 

I have a visualforce page which I am passing data from into apex code and using input from the page to update an object.

 

In this example I have a table of data, each ending with a checkbox and a text field.  the text field is disabled until the user ticks the checkbox.  at that point, I use javascript to enable the text field.

When the user is done they click a submit button which calls apex code.

 

This all works fine when I dont have the javascript involved.  ie if the text box is always enabled, the data is passed and object updated fine, however when I do try and involve the javascript to enable/disable the text field as the checkbox is toggled, no data seems to be being passed from the text field and the object is not getting updated.  well, it is, just not that text field.

 

Does anyone have any ideas why this would be happening and if it cannot be fixed, is there another way to link the textfield to the checkbox?

 

Thanks

 

Steven

I have a lightning-datatable web component which is happily displaying data.  I have written an onsort function which is performing the sort correctly in the controller but is not rerendering the display of the table so nothing appears to change.

I know the rows are being sorted because the rows have view and edit actions and clicking these performs the action against the correctly sorted row, even if it doesn't match what's being displayed.  It's as if I need to manually trigger some kind of refresh to cause the data on the screen to be updated to match the data in the controller, but the data is @api decorated so it should be doing it automatically, as I understand it.

There's not much out there about lightning web components, wondered if someone on here could offer a suggestion?
 
<template>
    <lightning-datatable data={tblData}
                         columns={columns}
                         hide-checkbox-column={hideCheckboxColumn}
                         sorted-by={sortedBy}
                         sorted-direction={sortedDirection}
                         key-field={keyField}
                         onsort={updateColumnSorting}
                         onrowaction={handleRowAction}
    >
    </lightning-datatable>
</template>
import { LightningElement, api, track} from 'lwc';
import { CurrentPageReference, NavigationMixin } from 'lightning/navigation';

export default class DatatableSortableWeb extends NavigationMixin(LightningElement) {
    @api tblData = [];
    @api columns;
    @api hideCheckboxColumn;
    @api sortedBy;
    @api sortedDirection;
    @api keyField;

    /*
    If user clicks a column header, sort using event params
    */
    updateColumnSorting(event) {
        var fieldName = event.detail.fieldName;
        var sortDirection = event.detail.sortDirection;

        // assign the latest attribute with the sorted column fieldName and sorted direction
        this.sortedBy = fieldName;
        this.sortedDirection = sortDirection;
        this.tblData = this.sortData(fieldName, sortDirection);
    }

    /*
    Sort table, ignoring case and treating empty cells as "zzz" so they come last when sorting ASC
    */
    sortData(fieldName, sortDirection) {
        var dataToSort = this.tblData;
        var reverse = sortDirection !== 'asc';
        //sorts the rows based on the column header that's clicked
        dataToSort.sort(this.sortBy(fieldName, reverse));
        return dataToSort;
    }

    sortBy(field, reverse, primer) {
        var key = primer ?
            function(x) {return primer(x.hasOwnProperty(field) ? (typeof x[field] === 'string' ? x[field].toLowerCase() : x[field]) : 'zzz')} :
            function(x) {return x.hasOwnProperty(field) ? (typeof x[field] === 'string' ? x[field].toLowerCase() : x[field]) : 'zzz'};

        //checks if the two rows should switch places
        reverse = !reverse ? 1 : -1;
        return function (a, b) {
            return a = key(a), b = key(b), reverse * ((a > b) - (b > a));
        }
    }


 
I have a lightning-datatable web component which is happily displaying data.  I have written an onsort function which is performing the sort correctly in the controller but is not rerendering the display of the table so nothing appears to change.

I know the rows are being sorted because the rows have view and edit actions and clicking these performs the action against the correctly sorted row, even if it doesn't match what's being displayed.  It's as if I need to manually trigger some kind of refresh to cause the data on the screen to be updated to match the data in the controller, but the data is @api decorated so it should be doing it automatically, as I understand it.

There's not much out there about lightning web components, wondered if someone on here could offer a suggestion?
 
<template>
    <lightning-datatable data={tblData}
                         columns={columns}
                         hide-checkbox-column={hideCheckboxColumn}
                         sorted-by={sortedBy}
                         sorted-direction={sortedDirection}
                         key-field={keyField}
                         onsort={updateColumnSorting}
                         onrowaction={handleRowAction}
    >
    </lightning-datatable>
</template>
import { LightningElement, api, track} from 'lwc';
import { CurrentPageReference, NavigationMixin } from 'lightning/navigation';

export default class DatatableSortableWeb extends NavigationMixin(LightningElement) {
    @api tblData = [];
    @api columns;
    @api hideCheckboxColumn;
    @api sortedBy;
    @api sortedDirection;
    @api keyField;

    /*
    If user clicks a column header, sort using event params
    */
    updateColumnSorting(event) {
        var fieldName = event.detail.fieldName;
        var sortDirection = event.detail.sortDirection;

        // assign the latest attribute with the sorted column fieldName and sorted direction
        this.sortedBy = fieldName;
        this.sortedDirection = sortDirection;
        this.tblData = this.sortData(fieldName, sortDirection);
    }

    /*
    Sort table, ignoring case and treating empty cells as "zzz" so they come last when sorting ASC
    */
    sortData(fieldName, sortDirection) {
        var dataToSort = this.tblData;
        var reverse = sortDirection !== 'asc';
        //sorts the rows based on the column header that's clicked
        dataToSort.sort(this.sortBy(fieldName, reverse));
        return dataToSort;
    }

    sortBy(field, reverse, primer) {
        var key = primer ?
            function(x) {return primer(x.hasOwnProperty(field) ? (typeof x[field] === 'string' ? x[field].toLowerCase() : x[field]) : 'zzz')} :
            function(x) {return x.hasOwnProperty(field) ? (typeof x[field] === 'string' ? x[field].toLowerCase() : x[field]) : 'zzz'};

        //checks if the two rows should switch places
        reverse = !reverse ? 1 : -1;
        return function (a, b) {
            return a = key(a), b = key(b), reverse * ((a > b) - (b > a));
        }
    }


 
Hi All,
I am new to the Lightning Components,can any one provide the sample  code for creating the custom clonebutton for Quote object.
how to learn the lightning components deeply,can any one provide the lightning blogs.
thanks in advance
Hi, 

For a couple of days I've been receiving this kind of line in my debug logs. I guess this is realated to the new API version (v37.0). 
I would n't care about this if didn't receive thousands of lines like this one in all my traces. 

17:02:42.238 (238882742)|USER_INFO|[EXTERNAL]Salesforce user id| username| GMT time

My debugs levels are: 

Database               INFO
Workflow                INFO
Validation               INFO
Callouts                 INFO
Apex Code            INFO
Apex Profiling        DEBUG
Visualforce            NONE
System                 NONE

Thanks
Hello everybody and especially sports lovers out there!

One of our clients is actually a major sports league in France! and at the moment, we're developping a system based on salesforce to manage all the teams, matches, statistics... etc. So here's my question:

I'm creating a batch that launches every week. this batch must update a player statistics (points, red cards, subtitutions...etc) per competition. the data is taken from a custom object called "composition equipe" that has all the data related to the player and then we must put the data per player AND per competition in a new custom object called "statistique joueur competition" (joueur= player) 

To furthur explain, here's a scenario:

Let's say a player Mike scores 3 points today and 4 points next week in a competition called "league". The same Mike also scores 2 points today and 3 next week in a competition called "friendly match"

In the end, we must have in our new object "statistique joueur competition" the following records: "Mike League. 7 points" and "Mike freindly match. 5 points"

so my trouble is to find the key that combines the player and the competition together. I tried nested queries but the system only allows 2 levels of queries and there are 4 levels between my objects.

Here's a quick topology of the objects in question:

Player= contact
Parent child relationships between objects: Competition -> Match -> Composition -> Composition Equipe

I hope that it's clear for everybody. if it's not, I'd be happy to explain furthur more.

I'm also new to coding by the way!

Thanks a lot for your help :)

​Hi everyone,

We are using a visualforce page to host buttons to create case related emails.
The problem is that the Thread ID gets expanded by 3 digits and gets added at the top of the email for no reason.
for example, it changes from [ ref:_00D30ups._50040qCn7G:ref ] to [ ref:_00D30ups._50040qCn7GAAS:ref ]

It makes the system creates a new case insead.

The email-to-case setting is set NOT to include Thread ID in Subject or body, we have this as a field in the template itself.


Any help is appreciated.
 
I need to develop a page with a very large grid of data.  I'm affraid it may exceed view state limits.

I know I could code it all in HTML with my choice of JS framework with JS remoting to get an write data.  But that's is an increased coding effort and also loses the SF look and feel.

What I'd like to do instead of develop some sort of hybrid page.  Use the VF tags like pageBlockTable column, etc. to get the SF look, but then on pageload have a script call javascript remote actions to get the full data which would be larger than 136K view state.  Then have various onChange events save pieces of data back to SF via other remove actions.  The only merge variable needed would be a master id to provide the intial script with a key so it could compose the calls to remote actions.

I wondering if maybe there could be some dummy empty tables and then a way to get scripts to fill them with data.

Anyone know if that architecture is doable and maybe have some examples anything like that?

How do I  run a report from a custom link, which selects records based on a date range

 

I want the user to enter start and end dates of the date range,and pass these to the report

 

The pv0, pv1 method seems to only reference fields in the current record

 

I want to ask for two dates then pass these to the report

  • March 19, 2012
  • Like
  • 0

Is there a way to add the attachement related list on a visualforce page? Can anyone give me some code samples ?

Hi,

 

I have my accounts related on a way that one parent Account is pointed by its daughters with the field ParentId.

 

I need to do a trigger that when the parent account is modified in the field Recovery_actions__C(is a checkfield), this change has to go to the daughters accounts.

 

This is my trigger:

 

trigger UpdateCierrePorRecobro on Account (beforeupdate) {

 

Set<Id> addAccountsActivate = newSet<Id>();

Set<Id> addAccountsDeactivate = newSet<Id>();

 

//Aislo los id's

 

for(integer i=0;i<Trigger.new.size();i++){

//If the value has changed add to the list

if ((Trigger.new[i].Recovery_Actions__c!=Trigger.old[i].Recovery_Actions__c)) { 

if (trigger.new[i].recovery_actions__c){//changed to true

addAccountsActivate.add(Trigger.new[i].id);

}

else{//changed to false

addAccountsDeactivate.add(Trigger.new[i].id);

}

}

}

if(addAccountsActivate.size()>0){

 

//create a list of ids with the daughter ids of the main account

//????????????????????????????????????????

List<id> listaToTrue=newList<id>();

listaParaActivar.add([select id fromAccountwhereParentId in:addAccountsActivate]);

//????????????????????????????????????????????

 

Accountacc;

 

//and update the value

for(integer j=0;j<listaToTrue.size();j++){

acc.id=listaParaActivar[j];

acc.Reacovery_Actions__c=1;

updateacc;

}

}

 

}

 

 

---------------------------------------

 

I have the problem in the part where I query in order to get the ids of the daughter accounts, I dont know how to get that list of ids.

 

Anyone could help here?

 

Thanks,

Antonio

Hi Guys,

 

I have a developed a visualforce page which is when opened in an Internet Explorer (v 8) shows an error in the status bar as 'Object required'. It shows the line number as well.

I have observed this typical behavior of the page with Internet Explorer only.There are issues with the mozilla firefox.

(v 3.6.20 )


Also a small question regarding this behavior - Does VF pages behave differently with different browsers ?

 

Please Suggest.

 

 Thanks and Regards,

 

gk_myguru

Hi all,

I'm using a StandardSetController to hold lots of records but through pagination, only display a few at a time in a pageblocktable.

It's holding cases.  If I run a query which populates the SSC with several thousand cases I'm getting the Maximum view state size limit (135KB) exceeded errors.  The pageSize is set to just 20, so why am I getting this issue?!  I thought the whole point of using a SSC was to get around this issue?  It seems that even though my page size is 20, the view state is holding EVERY record in the SSC, which is several thousand and causing this issue.

 

Why am I getting this error despite using pagination?

 

Thanks

Hey guys, I'm brand new to Apex and VisualForce.

 

I'm trying to find a way that I can build a dynamic email signature into my email template so that whoever is sending the email has his/her Name, Title, Phone, Mobile, and Email

 

I've tried this:

                   <p><font color="#CC0000">+</font> {!$User.name}<br />
                    <b>{!$User.owner.title}</b><br />
                    123 Holla Back St<br />
                     NEW YORK, NY 10014<br />
                    W: {!$User.phone}<br />
                    C: {!$User.mobile}<br />
                    {!$User.email}</p>

 

Been trying to look for another discussion board trying to make this work but unsuccessful.

  • July 01, 2011
  • Like
  • 1

Hello,

I'm struggling to come up with an answer to this by myself so thought Id throw it out there.

 

Sometimes if a SOQL query returns no results it throws an exception, which can be caught and then the field populated differently, ie created.  However sometimes it doesn't throw an exception so I have to wrap my query in a try{catch} and then outside of that, also check to make sure the return isn't null so I can handle that too.

 

Is there a logical reason why it does this?  It's making my code unnecessarily long and at best, is just annoying!

 

Thanks for any replies

Steven

hi all, this is my first post, made in desperation after searching to try and find this solution already discussed but no luck so far.

 

my problem is the restrictions on the behaviour of the inbuilt send email button in only lookingup contacts or person accounts. - I need to use the 'send email' functionality from my custom object (in order to merge the custom object field data into the email template) to send emails to leads as well as accounts, and I don't want to convert these leads at this stage just so that I can send them this email (I intend to automate this email being send to new leads on creation in the future).

 

I understand that I need to use a custom 'send email' button in replacement of the standard one, and the code for this button should facilitate contacts/person account and leads both being permitted in the recipient lookup.

 

has anyone built this already and can help me out?

 

thanks

Hi, 

For a couple of days I've been receiving this kind of line in my debug logs. I guess this is realated to the new API version (v37.0). 
I would n't care about this if didn't receive thousands of lines like this one in all my traces. 

17:02:42.238 (238882742)|USER_INFO|[EXTERNAL]Salesforce user id| username| GMT time

My debugs levels are: 

Database               INFO
Workflow                INFO
Validation               INFO
Callouts                 INFO
Apex Code            INFO
Apex Profiling        DEBUG
Visualforce            NONE
System                 NONE

Thanks