• Sylvie Serplet
  • NEWBIE
  • 124 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 38
    Questions
  • 70
    Replies
Hi all,
I have a custom object where I enter every month sales data. I have the need to display on each record the value of the same field for the previous month. The record need also to fullfill other criteria such as same sales name, same year....
I have created a formula field but it is not working. Any thought?
IF( 
AND( 
Year__c = YEAR(DATEVALUE(CreatedDate)), 
MONTH(DATEVALUE(CreatedDate)) = MONTH(TODAY()) -1, 
Sales_Team__c = Sales_Team__c, 
Branch__c = Branch__c, 
), 
No_of_Clients__c, null 
)
Thank you in advance for your help.
Sylvie
Hi All,

Need help improving my test class. Current coverage is 47%!

VF Page
<apex:page controller="WorkCtr" lightningStylesheets="true" >
    <apex:slds />
    <div class="slds-scope">
        <apex:form >
            <apex:pageBlock >
                <apex:pageblocksection columns="2">                     
                    <apex:inputField value="{!wr.Date__c}"/>                    
                    <apex:inputField value="{!wr.Name__c}"/>  
                    <apex:inputField value="{!wr.Comment__c}"/>     
                </apex:pageblocksection>
                <apex:pageBlockSection columns="1">
                    <apex:pageBlockTable value="{!walist}" var="wa">
                        <apex:column headerValue="Percentage">
                            <apex:inputField value="{!wa.Percentage__c}"/>
                        </apex:column>
                        <apex:column headerValue="Assigned To">
                            <apex:inputField value="{!wa.Assigned_to__c}"/>
                        </apex:column>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>
                <apex:pageBlockButtons location="bottom">
                    <apex:commandButton value="Save" action="{!save}" />    
                    <apex:commandButton value="Add Row" action="{!AddRow}" immediate="true"/>
                </apex:pageBlockButtons>
            </apex:pageBlock>      
        </apex:form>
    </div>
</apex:page>
APEX Class
public with sharing class WorkCtr {

    public Workload__c wr{get;set;}
    public list <Work__c> walist{get;set;}    
    
    public WorkCtr() {  
        wr = new Workload__c();
        walist = new List <Work__c>();
        AddRow();          
    }
    public void AddRow(){
        walist.add(new Work__c());
    }
    public void save(){        
        if(wr.name__c !=null){
            insert wr;
            List <Work__c> wal = new List <Work__c>();
            for (Work__c w: walist) {
                w.Workload__c = wr.Id;   
                w.Date__c = wr.Date__c;
                wal.add(w);
            }
            if(wal !=null) {
                insert wal;
                
        wr = new Workload__c();
        walist = new List <Work__c>();
        AddRow();   
            }
        }
    }
}
Test Class
@isTest
private class WorkCtrTest {
    static testMethod void WorkCtrTest(){
           
        Account acc = new Account();
        acc.Name = 'Test Account';
        insert acc ;
        
        Contact con = new Contact();
        con.AccountId = acc.Id;
        con.LastName ='Test Name';
        insert con;
        
        Contact con1 = new Contact();
        con1.AccountId = acc.Id;
        con1.LastName ='Test Name';
        insert con1;
        
        Workload__c wr = new Workload__c();
        wr.Comment__c = 'This a test comment';
        wr.Name__c = con.Id;
        wr.Date__c = System.Today();       
        insert wr;    
        
        Work__c w = new Work__c();
        w.Assigned_to__c = con.Id ;
        w.Date__c = wr.Date__c;
        w.Percentage__c = 50;
        w.Workload__c = wr.Id;       
        insert w;
        
        Work__c w1 = new Work__c();
        w1.Assigned_to__c = con1.Id ;
        w1.Date__c = wr.Date__c;
        w1.Percentage__c = 30;
        w1.Workload__c = wr.Id; 
        insert w1;
                   
        Test.StartTest();
        
        WorkCtr obj = new WorkCtr();           
        obj.save();
        
        Test.StopTest();    
    }
}

Thanks in advance for your help.
Sylvie​
Hi,
I am trying to set a validation rules when an opportunity is closed won. 
When  IsWon is true and the record type is MyRecordType all the following fields need to be completed (fields 1,2,3 are picklists and field 4 is date).
My code is:
AND( 
IsWon = true, 
$RecordType.Name = "myrecordtype", 
ISBLANK(TEXT(field1)), 
ISBLANK(TEXT(field2)), 
ISBLANK(TEXT(field3)), 
ISBLANK(field4) 
)
The rule works the first time the user try to close the opportunity, but if only one field (field 1 for example) is completed, the rule does not execute again and the opportunity can be closed even if the 3 other fields are empty. Is it a normal behaviour or my validation is wrong?

Thank you for your help.
Sylvie  
 
Hi,
I am trying to implement the new lightning:recordForm for a component that need to diplay on Home page. The result does not look right (fields are packed on the left of the screen as below) on Home page but diplay correctly on another custom lightning tab.
Do I missed something or is it a bug?

User-added image

My code:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
    
    <aura:attribute name="fields" type="List" default="Name,OwnerId,CSB_Name__c,Date__c,Overdue_Tasks__c,Unactioned_Emails__c,Comment__c"/>
    
    <lightning:card iconName="custom:custom19" title="Create New Workload" >
        <div class="slds-p-left_large slds-p-right_medium">	
            <lightning:recordForm aura:id="form"
                                  objectApiName="Workload_Register__c" 
                                  fields = "{!v.fields}"
                                  columns = "1"
                                  mode = "Edit"
                                  onsubmit = "{!c.handleSubmit}"
                                  onsuccess="{!c.handleSuccess}"                          
                                  onerror="{!c.onError}"
                                  />
        </div>
    </lightning:card>  
    
</aura:component>

Thank you in advance for your help.
Sylvie
Hi all,

I have a VF page using SLDS markup (I am in LEX) and I would like to implement expandable/collapsible sections in my form.

This is a code for one of my section with SLDS Expandable section https://www.lightningdesignsystem.com/components/expandable-section/
<div class="slds-form slds-form_compound">
                <fieldset class="slds-box slds-theme--default slds-container--medium slds-align_absolute-center"> 
                    <div class="slds-section">
                        <h3 class="slds-section__title">
                            <button class="slds-button slds-section__title-action" aria-controls="content" aria-expanded="false">
                                <svg aria-hidden="true" class="slds-section__title-action-icon slds-button__icon slds-button__icon--left" aria-hidden="true">
                                    <use xmlns:xlink="http://www.w3.org/1999/xlink" 
                                         xlink:href="/apexpages/slds/latest/assets/icons/utility-sprite/svg/symbols.svg#switch"></use>
                                </svg>XXXX</button>
                        </h3>
                        <div class="slds-section__content" id="content" aria-hidden="true" >
                            <div class="slds-form-element">
                                <label class="slds-form-element__label" >ABC</label>
                                <div class="slds-form-element__control">
                                    <apex:inputfield value="{!FF.ABC}" styleClass="slds-input"/>
                                </div>
                            </div>                 
                            <div class="slds-form-element">
                                <label class="slds-form-element__label" ">XYZ</label>
                                <div class="slds-form-element__control">
                                    <apex:inputfield value="{!FF.XYZ}" styleClass="slds-input"/>
                                </div>
                            </div> 
....
</fieldset>
            </div>
I have tried to implement this solution with jquery: http://www.minerva18.com/blog/creating-expandablecollapsible-lightning-design-sections-in-salesforce/#comment-1763 but the section open only for a few second and close again and the screen jump to the top of the page (I am using Chrome). 

I have also tried other solutions such as
<script type="text/javascript">
    function toggle_visibility() {
   var e = document.getElementById('content'); 
          if(e.style.display == 'none')
          e.style.display = 'block';
       else
          e.style.display = 'none';
    }
</script>

adding onclick="toggle_visibility();" on the button
or
function showContent() {
   {
        document.getElementById('content').style.visibility="visible";
    }
    else
    {
        document.getElementById('content').style.visibility="hidden";
    }
}
or
$(function () { 
    $('content').on('click', function (e) {
        var menuItem = $( e.currentTarget );

        if (menuItem.attr( 'aria-expanded') === 'true') {
            $(this).attr( 'aria-expanded', 'false');
            $(this).attr( 'aria-hidden', 'true')
        } else {
            $(this).attr( 'aria-expanded', 'true');
            $(this).attr( 'aria-hidden', 'false')
        }
    });
});

using jquery: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

But nothing is working.
Any help will be greatly appreciated!
Sylvie
Hi All,

I have written a Trigger to update a custom field (Account__c) on ContentVersion.
The Trigger does not have any error but when I try to updload a file in an Account I got an error message "Can't updload (file name)".
Something wrong with the Trigger but I can't figure it why. 
trigger UpdateAccountonFile on ContentVersion (after insert) {

    Set<Id> docIds = new Set<Id>();
    
    for(ContentVersion cv : trigger.new){  
       
      if(cv.ContentDocumentId != null)
            {
                docIds.add(cv.ContentDocumentId);
        }  
    }     
  ContentDocumentLink c = [SELECT ContentDocument.Id, ContentDocument.Title, Id, LinkedEntityId FROM ContentDocumentLink WHERE ContentDocument.Id In:docIds ];   
    
   List<Account> accList = [SELECT Id, name FROM Account WHERE Id =:c.LinkedEntityId ];            
    
    for(ContentVersion cv : trigger.new){      
        
        if(accList.size() > 0){
            for(Account a : accList){
                cv.Account__c = a.Id;
            }
        }
        else{
            cv.Account__c = null; 
        }            
    }
}

Thanks in advance for your help.
Sylvie 
 
Hi All,
I am trying to create an Apex Trigger to update a custom field on Files (ContentVersion object) with the LinkedEntityId (ContentDocumentLink object).
Any idea how to do it?
Thank you in advance for your help.
Sylvie
 
Hi all,
I have created custom Account fields on several of my objects.
When an email is created on these objects, the Account field need to be automatically populated. To do so, I have created an APEX trigger which is working perfectly fine for 5 of my objects (I give only 2 examples in my code below) but it does not work for Case. I cannot understand why. Any thought?
trigger UpdateAccountonEmail on EmailMessage (before insert, before update) {
    
    for(EmailMessage em : trigger.new){
        
        if(em.RelatedToId != null){ 
            
            List<Account> accList = [select id, name from Account where id =: em.RelatedToId]; 
            List<Opportunity> oppList = [select id, name, AccountId from Opportunity where id =: em.RelatedToId];        
            List<Case> casList = [select id, CaseNumber, AccountId from Case where id =: em.RelatedToId];
            
         // Account field is populated when an email is created on Opportunity  
            ​if(oppList.size() > 0){
                for(Opportunity o : oppList){
                    em.Account__c = o.AccountId;                
                }
            }
          // Account field is populated when an email is created on Account
            else if(accList.size() > 0){
                for(Account a : accList){
                    em.Account__c = a.Id;
                }
            }
       // Account field is not populated when an email is created on Case       
            else if(casList.size() > 0){
                for(Case ca : casList){
                    em.Account__c = ca.AccountId;                
                }
            }
            else{
                em.Account__c = null; 
            }            
        }
    }
}

I have also noted a very strange behaviour, when I create an email into a case sometimes it stays as an email (test email case 3 below), sometimes it creates a task (Email: test email case 2 below) with the type email. How to avoid or streamline this?

User-added image

Thank you for your help.
Sylvie

 
Hi All,
I try to show on a Parent Account (checkbox) that it has a child Account in the hierachy of Accounts.
Below is my trigger but it does not work.
I have also tried Process Builder but could not make the criterias right.
Any Ideas?
trigger UpdateHierachyAccount on Account (after insert, after update) {
    
    Set<Id> accountIds = new Set<Id>();
    
    for (Account acc : Trigger.new) {
        if (acc.ParentId != null){
            accountIds.add(acc.Id);
        }
        
        List<Account> accounts = [select id, Has_Child_Account__c from account where id in :accountIds ];
        
        for(Account a : accounts) {        
            a.Has_Child_Account__c = true;
        }   
        update accounts;
    }
}

Thank you in advance for your help.
Sylvie
Hi All,
I am trying to retrieve a list of records for a custom object (Fact_Finder__c) which has the same Account name as the Opportunity in where the list is displayed (in a Ligthning Component). There is a master detail relationship between the Opportunity (parent) and the Fact Finder (child).
My current code (below) retrieve records for this particular Opportunity but what I want to achieve is retrieving all the Fact Finders with the same Account name in all Opportunities.


public with sharing class FFsamePolicysameClient {
   
    @AuraEnabled     
    public static List<Fact_Finder__c> getallFF(String recordId){ 
       List <Fact_Finder__c> FF = [SELECT Id, Name, RecordType.Name, Date__c, Client_Name__r.Name, Policy__r.Name, Opportunity_Name__r.Name FROM Fact_Finder__c Where (Opportunity_Name__c =:recordId) ORDER BY Date__c DESC];
      return FF;        
    }
}

 I have tried many different ways but nothing seams to work.
Any help will be greatly appreciated.
Thanks in advance.
Sylvie

 
Hi all,
I am trying to write a SOQL but could not make it right.
Parent object Policy__c, child object Fact_Finder__c. Lookup relationship between the 2.
What I try to achieve is for all Policy that do not have a Fact Finder (id=null) or one but dated for more than 3 years (Date__c < LAST_N_YEARS:3) update the field on Policy, FactFinderDue = true.
Here is my code:
global class UpdatePolicywhenFactFinderisDue implements Schedulable { 
    
    global void execute(SchedulableContext ct) { 
        
        List<Policy__c> policylist = [Select Id, Name, Status__c, (Select Id, Date__c From Facts_Finder__r where Date__c < LAST_N_YEARS:3 or Id = null ) From Policy__c where Status__c='Current'];
        
        for (Policy__c po :policylist){
            po.FactFinderDue__c = true;    
        }
        update policylist; 
    }   
}
Thank you in advance for your help.
Sylvie

 
Hi all,
I have a Lightning Record Page with a standard Tabs Component and a standard Path Component.
What I would like to achieve is when a Stage is marked as complete on the Path Component a different tab get focus on the Tabs Component.
Is it possible? I made some research but could only find solution for Custom Lightning Component not Standard ones. 
Thank you in advance for your help. 
Sylvie
Hi All,
These are my Controller and my Test Class.
Whatever I change I could not reach more than 50% coverage.
Could you please help me to get at least 75% to deploy in Production?
public class MyCPDPointsAPEXController {
    
@AuraEnabled    
    public CPD_Points_Total__c total {get;set;}
    string recordId = ApexPages.currentPage().getParameters().get('recordId');
    
    public MyCPDPointsAPEXController(ApexPages.StandardController controller) { 
        
        total = [select Id, Name, Total_Points__c, (select Id, Activity_Date__c, Activity_Title__c, Organiser_Company__c, Points__c from CPD_Register__r) from CPD_Points_Total__c where Id=:ApexPages.currentPage().getParameters().get('recordId')];
    }
    
    public PageReference cancel(){   
        return new PageReference('/' + recordId);   
    }
}
 
@isTest
private class MyCPDPointsAPEXTest {
    
    static testMethod void MyTest()
    {
        CPD_Points_Total__c total = new CPD_Points_Total__c(Name='Test-2017');  
        
        ApexPages.CurrentPage().getparameters().put('id', total.id);      
        
        Apexpages.StandardController sc = new Apexpages.StandardController(total);
        MyCPDPointsAPEXController ext = new MyCPDPointsAPEXController(sc); 
        
        ext.cancel();      
    }
}



Thank you in advance for your help.
Sylvie
 
Hi all,

When I am writing test class for SOQL query I generally get 100% coverage with very basic lines of code, but for this one I got an error message "Method does not exist or incorrect signature: void getMyPoints() from the type Controller". Could you please help?
Thank you.

APEX Class
public class MyCPDPointsThisYearAPEXController {
     
   @AuraEnabled
    public static CPD_Points_Total__c getMyPoints(Id ID){        
        
        if (ID ==null){
        return [select Id, Name, CPD_Year__c, Total_Points__c from CPD_Points_Total__c where (Contact_ID_Test__c = 1 or Contact_ID_HO_Test__c = 1) and (CreatedDate = THIS_YEAR) LIMIT 1] ;     
        }
        
        List<CPD_Points_Total__c> points = [select Id, Name, CPD_Year__c, Total_Points__c from CPD_Points_Total__c where (Id = :ID) and  (Contact_ID_Test__c = 1 or Contact_ID_HO_Test__c = 1) and (CreatedDate = THIS_YEAR) LIMIT 1] ;     
       
        if (points.size() ==0){
            return [select Id, Name, CPD_Year__c, Total_Points__c from CPD_Points_Total__c where (Contact_ID_Test__c = 1 or Contact_ID_HO_Test__c = 1) and (CreatedDate = THIS_YEAR) LIMIT 1] ;     
        }else {            
            return points[0];
        }          
    }     
}

Test Class
@isTest
public class MyCPDPointsAPEXControllerTest {
    
    static testMethod void MyTest(){  
        
        List<CPD_Points_Total__c> myPoints = new List<CPD_Points_Total__c>();
        
        CPD_Points_Total__c p1 = new CPD_Points_Total__c();
        p1.name='Test Name';
        p1.CPD_Year__c='2017';
        myPoints.add(p1);
        
        CPD_Points_Total__c p2 = new CPD_Points_Total__c();
        p2.name='Test Name2';
        p2.CPD_Year__c='2017';
        myPoints.add(p2);
        
        insert myPoints;   
        
        MyCPDPointsThisYearAPEXController controller = new MyCPDPointsThisYearAPEXController();
        controller.getMyPoints();
    }
}


 
Hi  
I have a Lightning Component and want to display a inside a VF page. I read that the solution is to use Iframe, but it is not working for me.
Result (empty)
User-added image 
Component
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" access="global">
    
    <fieldset class="slds-box slds-container--fluid">
        <header class="slds-card__header slds-grid">
          <div class="slds-media slds-media--center slds-has-flexi-truncate">
                <div class="slds-media__figure"> 
                    <span class="slds-icon__container slds-icon-standard-account">
                        <c:svg class="slds-icon" xlinkHref="/resource/SLDS202/assets/icons/custom-sprite/svg/symbols.svg#custom31" />
                        <span class="slds-assistive-text">Transaction Icon</span>
                    </span>  
                </div>
                <div class="slds-media__body slds-truncate">
                    <h2><span class="slds-section__title" style="font-weight: bold;">Policies and Transactions</span></h2>
                </div>
            </div>	
        </header>
    
        <iframe src="{!'https://ausurebroking--partials.cs57.visual.force.com/apex/PoliciesAndTransactions'}" width="100%" height="300px;" frameBorder="0"/>

    </fieldset>
</aura:component>
What I am missing?
Thank you for your help.
Sylvie

 
Hi,
I have a Lightning Component that display a simple value and need a conditional formating depending of the value. The component display the correct value but my if statement to set the color is not working. Could you please tell me what is wrong with my code? Thanks in advance for your help.

Result (should be green)
User-added image
Component
<aura:component controller="MyCPDPointsThisYearAPEXController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
 
    <aura:attribute name="status" type="String" /> 
    <aura:attribute name="myPoints" type="CPD_Points_Total__c" />
    <aura:attribute name="ID" type="String" />      
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    <lightning:card title="{! 'My CPD Points for ' + v.myPoints.CPD_Year__c}" >    
        <p class="slds-p-horizontal--small slds-align_absolute-center" >
             <div aura:id="chart" >
                <lightning:layout >
                    <lightning:layoutitem class="{! 'points-block ' + v.status}" >
                        <div class="points">{!v.myPoints.Total_Points__c}</div>points  
                    </lightning:layoutitem>                                    
                </lightning:layout>
             </div> 
            </p>  
    </lightning:card>
</aura:component>

Javascript Controller
({
    doInit : function(component) {       
        
        var action = component.get("c.getMyPoints");    
        action.setParams ({
            ID :component.get("v.ID")                         
        })         
        action.setCallback(this, function(actionResult) {    
            component.set("v.myPoints", actionResult.getReturnValue());
            
        var status ;
            var totalpoints = "Total_Points__c";
            if (totalpoints > 25){
                status = "green";
            } else {
                status = "orange";
            }            
            component.set("v.status", status);

        });        
        
        $A.enqueueAction(action);     
    }
})
Style
.THIS .points-block {
	text-align: center;
    margin-right: 8px;
    padding: 8px 12px;
    border-radius: 0.25rem;
    border: solid 1px rgb(216, 221, 230);
} 
.THIS .points-block.green {
	color: #008000;
    border: solid 3px #008000;
} 
.THIS .points-block.orange {
	color: #ff6633;
    border: solid 3px #ff6633;
} 
.THIS .points {
	font-size: 32px;
	line-height: 32px;
	font-weight: 500;
    margin-right: 12px;
    margin: 0;
    padding: 0;
} 
.THIS .chart {
    position: relative;
    height: 40px;
}
APEX Controller
public class MyCPDPointsThisYearAPEXController {
     
   @AuraEnabled
    public static CPD_Points_Total__c  getMyPoints(Id ID){        
        
        if (ID ==null){
        return [select Id, CPD_Year__c, Total_Points__c from CPD_Points_Total__c where (Contact_ID_Test__c = 1 or Contact_ID_HO_Test__c = 1) and (CreatedDate = THIS_YEAR) LIMIT 1] ;     
        }
        
        List<CPD_Points_Total__c> points = [select Id, CPD_Year__c, Total_Points__c from CPD_Points_Total__c where (Id = :ID) and  (Contact_ID_Test__c = 1 or Contact_ID_HO_Test__c = 1) and (CreatedDate = THIS_YEAR) LIMIT 1] ;     
       
        if (points.size() ==0){
            return [select Id, CPD_Year__c, Total_Points__c from CPD_Points_Total__c where (Contact_ID_Test__c = 1 or Contact_ID_HO_Test__c = 1) and (CreatedDate = THIS_YEAR) LIMIT 1] ;     
        }else {            
            return points[0];
        }         
    }     
}

 
I would like to create a Lightning Component with a progress bar that display the next 30 days split in 4 section for weeks and summarize the number of opportunities by weeks on top. Something like this:
User-added image
If not possible in Lightning a VF page or even a report will do.
Any idea how to do it?
Thank you in advance for your help.
Sylvie
Hi All,
I have a VF page styled with SLDS to use in Lightning. I have an apex command buttonin the page that is using a styleClass 'slds-button-neutral.' This button is used to hide or display some elements on the page. What I would like to do is changing its appearance to sld-button-brand when clicked and back to neutral when click again. Any idea how to achieve that? Could not find any solution on the web except using CSS but not SLDS.
Thanks in advance for your help.
Sylvie
 
I have created Lightning email templates into a custom object and would like to retrieve their Ids to use in an Apex class to setTemplateId.
Where are they stored in Salesforce I can't find them?
Thank you.
Hi all,
I have created a Lightning email template on a custom object with a merge field with data type formula(currency).
When I display the email in Salesforce in the activity timeline the field display properly but when I send the email (I tried, Outlook 2010, Outlook.com and Gmail) I get an (?) after the amount (as display below).
User-added image
How can I fix this?
Thanks in advance for your help.
Sylvie
 
Hi all,
I have a custom object where I enter every month sales data. I have the need to display on each record the value of the same field for the previous month. The record need also to fullfill other criteria such as same sales name, same year....
I have created a formula field but it is not working. Any thought?
IF( 
AND( 
Year__c = YEAR(DATEVALUE(CreatedDate)), 
MONTH(DATEVALUE(CreatedDate)) = MONTH(TODAY()) -1, 
Sales_Team__c = Sales_Team__c, 
Branch__c = Branch__c, 
), 
No_of_Clients__c, null 
)
Thank you in advance for your help.
Sylvie
Hi All,

Need help improving my test class. Current coverage is 47%!

VF Page
<apex:page controller="WorkCtr" lightningStylesheets="true" >
    <apex:slds />
    <div class="slds-scope">
        <apex:form >
            <apex:pageBlock >
                <apex:pageblocksection columns="2">                     
                    <apex:inputField value="{!wr.Date__c}"/>                    
                    <apex:inputField value="{!wr.Name__c}"/>  
                    <apex:inputField value="{!wr.Comment__c}"/>     
                </apex:pageblocksection>
                <apex:pageBlockSection columns="1">
                    <apex:pageBlockTable value="{!walist}" var="wa">
                        <apex:column headerValue="Percentage">
                            <apex:inputField value="{!wa.Percentage__c}"/>
                        </apex:column>
                        <apex:column headerValue="Assigned To">
                            <apex:inputField value="{!wa.Assigned_to__c}"/>
                        </apex:column>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>
                <apex:pageBlockButtons location="bottom">
                    <apex:commandButton value="Save" action="{!save}" />    
                    <apex:commandButton value="Add Row" action="{!AddRow}" immediate="true"/>
                </apex:pageBlockButtons>
            </apex:pageBlock>      
        </apex:form>
    </div>
</apex:page>
APEX Class
public with sharing class WorkCtr {

    public Workload__c wr{get;set;}
    public list <Work__c> walist{get;set;}    
    
    public WorkCtr() {  
        wr = new Workload__c();
        walist = new List <Work__c>();
        AddRow();          
    }
    public void AddRow(){
        walist.add(new Work__c());
    }
    public void save(){        
        if(wr.name__c !=null){
            insert wr;
            List <Work__c> wal = new List <Work__c>();
            for (Work__c w: walist) {
                w.Workload__c = wr.Id;   
                w.Date__c = wr.Date__c;
                wal.add(w);
            }
            if(wal !=null) {
                insert wal;
                
        wr = new Workload__c();
        walist = new List <Work__c>();
        AddRow();   
            }
        }
    }
}
Test Class
@isTest
private class WorkCtrTest {
    static testMethod void WorkCtrTest(){
           
        Account acc = new Account();
        acc.Name = 'Test Account';
        insert acc ;
        
        Contact con = new Contact();
        con.AccountId = acc.Id;
        con.LastName ='Test Name';
        insert con;
        
        Contact con1 = new Contact();
        con1.AccountId = acc.Id;
        con1.LastName ='Test Name';
        insert con1;
        
        Workload__c wr = new Workload__c();
        wr.Comment__c = 'This a test comment';
        wr.Name__c = con.Id;
        wr.Date__c = System.Today();       
        insert wr;    
        
        Work__c w = new Work__c();
        w.Assigned_to__c = con.Id ;
        w.Date__c = wr.Date__c;
        w.Percentage__c = 50;
        w.Workload__c = wr.Id;       
        insert w;
        
        Work__c w1 = new Work__c();
        w1.Assigned_to__c = con1.Id ;
        w1.Date__c = wr.Date__c;
        w1.Percentage__c = 30;
        w1.Workload__c = wr.Id; 
        insert w1;
                   
        Test.StartTest();
        
        WorkCtr obj = new WorkCtr();           
        obj.save();
        
        Test.StopTest();    
    }
}

Thanks in advance for your help.
Sylvie​
Hi,
I am trying to set a validation rules when an opportunity is closed won. 
When  IsWon is true and the record type is MyRecordType all the following fields need to be completed (fields 1,2,3 are picklists and field 4 is date).
My code is:
AND( 
IsWon = true, 
$RecordType.Name = "myrecordtype", 
ISBLANK(TEXT(field1)), 
ISBLANK(TEXT(field2)), 
ISBLANK(TEXT(field3)), 
ISBLANK(field4) 
)
The rule works the first time the user try to close the opportunity, but if only one field (field 1 for example) is completed, the rule does not execute again and the opportunity can be closed even if the 3 other fields are empty. Is it a normal behaviour or my validation is wrong?

Thank you for your help.
Sylvie  
 
Hi,
I am trying to implement the new lightning:recordForm for a component that need to diplay on Home page. The result does not look right (fields are packed on the left of the screen as below) on Home page but diplay correctly on another custom lightning tab.
Do I missed something or is it a bug?

User-added image

My code:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
    
    <aura:attribute name="fields" type="List" default="Name,OwnerId,CSB_Name__c,Date__c,Overdue_Tasks__c,Unactioned_Emails__c,Comment__c"/>
    
    <lightning:card iconName="custom:custom19" title="Create New Workload" >
        <div class="slds-p-left_large slds-p-right_medium">	
            <lightning:recordForm aura:id="form"
                                  objectApiName="Workload_Register__c" 
                                  fields = "{!v.fields}"
                                  columns = "1"
                                  mode = "Edit"
                                  onsubmit = "{!c.handleSubmit}"
                                  onsuccess="{!c.handleSuccess}"                          
                                  onerror="{!c.onError}"
                                  />
        </div>
    </lightning:card>  
    
</aura:component>

Thank you in advance for your help.
Sylvie
Hi all,

I have a VF page using SLDS markup (I am in LEX) and I would like to implement expandable/collapsible sections in my form.

This is a code for one of my section with SLDS Expandable section https://www.lightningdesignsystem.com/components/expandable-section/
<div class="slds-form slds-form_compound">
                <fieldset class="slds-box slds-theme--default slds-container--medium slds-align_absolute-center"> 
                    <div class="slds-section">
                        <h3 class="slds-section__title">
                            <button class="slds-button slds-section__title-action" aria-controls="content" aria-expanded="false">
                                <svg aria-hidden="true" class="slds-section__title-action-icon slds-button__icon slds-button__icon--left" aria-hidden="true">
                                    <use xmlns:xlink="http://www.w3.org/1999/xlink" 
                                         xlink:href="/apexpages/slds/latest/assets/icons/utility-sprite/svg/symbols.svg#switch"></use>
                                </svg>XXXX</button>
                        </h3>
                        <div class="slds-section__content" id="content" aria-hidden="true" >
                            <div class="slds-form-element">
                                <label class="slds-form-element__label" >ABC</label>
                                <div class="slds-form-element__control">
                                    <apex:inputfield value="{!FF.ABC}" styleClass="slds-input"/>
                                </div>
                            </div>                 
                            <div class="slds-form-element">
                                <label class="slds-form-element__label" ">XYZ</label>
                                <div class="slds-form-element__control">
                                    <apex:inputfield value="{!FF.XYZ}" styleClass="slds-input"/>
                                </div>
                            </div> 
....
</fieldset>
            </div>
I have tried to implement this solution with jquery: http://www.minerva18.com/blog/creating-expandablecollapsible-lightning-design-sections-in-salesforce/#comment-1763 but the section open only for a few second and close again and the screen jump to the top of the page (I am using Chrome). 

I have also tried other solutions such as
<script type="text/javascript">
    function toggle_visibility() {
   var e = document.getElementById('content'); 
          if(e.style.display == 'none')
          e.style.display = 'block';
       else
          e.style.display = 'none';
    }
</script>

adding onclick="toggle_visibility();" on the button
or
function showContent() {
   {
        document.getElementById('content').style.visibility="visible";
    }
    else
    {
        document.getElementById('content').style.visibility="hidden";
    }
}
or
$(function () { 
    $('content').on('click', function (e) {
        var menuItem = $( e.currentTarget );

        if (menuItem.attr( 'aria-expanded') === 'true') {
            $(this).attr( 'aria-expanded', 'false');
            $(this).attr( 'aria-hidden', 'true')
        } else {
            $(this).attr( 'aria-expanded', 'true');
            $(this).attr( 'aria-hidden', 'false')
        }
    });
});

using jquery: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

But nothing is working.
Any help will be greatly appreciated!
Sylvie
Hi All,

I have written a Trigger to update a custom field (Account__c) on ContentVersion.
The Trigger does not have any error but when I try to updload a file in an Account I got an error message "Can't updload (file name)".
Something wrong with the Trigger but I can't figure it why. 
trigger UpdateAccountonFile on ContentVersion (after insert) {

    Set<Id> docIds = new Set<Id>();
    
    for(ContentVersion cv : trigger.new){  
       
      if(cv.ContentDocumentId != null)
            {
                docIds.add(cv.ContentDocumentId);
        }  
    }     
  ContentDocumentLink c = [SELECT ContentDocument.Id, ContentDocument.Title, Id, LinkedEntityId FROM ContentDocumentLink WHERE ContentDocument.Id In:docIds ];   
    
   List<Account> accList = [SELECT Id, name FROM Account WHERE Id =:c.LinkedEntityId ];            
    
    for(ContentVersion cv : trigger.new){      
        
        if(accList.size() > 0){
            for(Account a : accList){
                cv.Account__c = a.Id;
            }
        }
        else{
            cv.Account__c = null; 
        }            
    }
}

Thanks in advance for your help.
Sylvie 
 
Hi All,
I am trying to create an Apex Trigger to update a custom field on Files (ContentVersion object) with the LinkedEntityId (ContentDocumentLink object).
Any idea how to do it?
Thank you in advance for your help.
Sylvie
 
Hi all,
I have created custom Account fields on several of my objects.
When an email is created on these objects, the Account field need to be automatically populated. To do so, I have created an APEX trigger which is working perfectly fine for 5 of my objects (I give only 2 examples in my code below) but it does not work for Case. I cannot understand why. Any thought?
trigger UpdateAccountonEmail on EmailMessage (before insert, before update) {
    
    for(EmailMessage em : trigger.new){
        
        if(em.RelatedToId != null){ 
            
            List<Account> accList = [select id, name from Account where id =: em.RelatedToId]; 
            List<Opportunity> oppList = [select id, name, AccountId from Opportunity where id =: em.RelatedToId];        
            List<Case> casList = [select id, CaseNumber, AccountId from Case where id =: em.RelatedToId];
            
         // Account field is populated when an email is created on Opportunity  
            ​if(oppList.size() > 0){
                for(Opportunity o : oppList){
                    em.Account__c = o.AccountId;                
                }
            }
          // Account field is populated when an email is created on Account
            else if(accList.size() > 0){
                for(Account a : accList){
                    em.Account__c = a.Id;
                }
            }
       // Account field is not populated when an email is created on Case       
            else if(casList.size() > 0){
                for(Case ca : casList){
                    em.Account__c = ca.AccountId;                
                }
            }
            else{
                em.Account__c = null; 
            }            
        }
    }
}

I have also noted a very strange behaviour, when I create an email into a case sometimes it stays as an email (test email case 3 below), sometimes it creates a task (Email: test email case 2 below) with the type email. How to avoid or streamline this?

User-added image

Thank you for your help.
Sylvie

 
Hi All,
I am trying to retrieve a list of records for a custom object (Fact_Finder__c) which has the same Account name as the Opportunity in where the list is displayed (in a Ligthning Component). There is a master detail relationship between the Opportunity (parent) and the Fact Finder (child).
My current code (below) retrieve records for this particular Opportunity but what I want to achieve is retrieving all the Fact Finders with the same Account name in all Opportunities.


public with sharing class FFsamePolicysameClient {
   
    @AuraEnabled     
    public static List<Fact_Finder__c> getallFF(String recordId){ 
       List <Fact_Finder__c> FF = [SELECT Id, Name, RecordType.Name, Date__c, Client_Name__r.Name, Policy__r.Name, Opportunity_Name__r.Name FROM Fact_Finder__c Where (Opportunity_Name__c =:recordId) ORDER BY Date__c DESC];
      return FF;        
    }
}

 I have tried many different ways but nothing seams to work.
Any help will be greatly appreciated.
Thanks in advance.
Sylvie

 
Hi all,
I am trying to write a SOQL but could not make it right.
Parent object Policy__c, child object Fact_Finder__c. Lookup relationship between the 2.
What I try to achieve is for all Policy that do not have a Fact Finder (id=null) or one but dated for more than 3 years (Date__c < LAST_N_YEARS:3) update the field on Policy, FactFinderDue = true.
Here is my code:
global class UpdatePolicywhenFactFinderisDue implements Schedulable { 
    
    global void execute(SchedulableContext ct) { 
        
        List<Policy__c> policylist = [Select Id, Name, Status__c, (Select Id, Date__c From Facts_Finder__r where Date__c < LAST_N_YEARS:3 or Id = null ) From Policy__c where Status__c='Current'];
        
        for (Policy__c po :policylist){
            po.FactFinderDue__c = true;    
        }
        update policylist; 
    }   
}
Thank you in advance for your help.
Sylvie

 
Hi  
I have a Lightning Component and want to display a inside a VF page. I read that the solution is to use Iframe, but it is not working for me.
Result (empty)
User-added image 
Component
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" access="global">
    
    <fieldset class="slds-box slds-container--fluid">
        <header class="slds-card__header slds-grid">
          <div class="slds-media slds-media--center slds-has-flexi-truncate">
                <div class="slds-media__figure"> 
                    <span class="slds-icon__container slds-icon-standard-account">
                        <c:svg class="slds-icon" xlinkHref="/resource/SLDS202/assets/icons/custom-sprite/svg/symbols.svg#custom31" />
                        <span class="slds-assistive-text">Transaction Icon</span>
                    </span>  
                </div>
                <div class="slds-media__body slds-truncate">
                    <h2><span class="slds-section__title" style="font-weight: bold;">Policies and Transactions</span></h2>
                </div>
            </div>	
        </header>
    
        <iframe src="{!'https://ausurebroking--partials.cs57.visual.force.com/apex/PoliciesAndTransactions'}" width="100%" height="300px;" frameBorder="0"/>

    </fieldset>
</aura:component>
What I am missing?
Thank you for your help.
Sylvie