• Pawel Borys
  • NEWBIE
  • 150 Points
  • Member since 2018

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 23
    Replies
COMPONENT
_____________
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="accClass">
   <aura:attribute name="data" type="List"/>
    <aura:attribute name="columns" type="List"/>
    <aura:handler name="init" value="{! this }" action="{! c.doInit }"/>
    <aura:attribute name="id1" type="id" />
    <lightning:navigation aura:id="navigate"/>
    <aura:attribute name="truthy" type="Boolean" Default ="true"/>
   
    <table class="slds-table slds-table--bordered slds-table--cell-buffer">
    <thead>
        <tr class="slds-text-title--caps">
            <th scope="col">
                <div class="slds-truncate" title="Name">Name</div>
            </th>
            <th scope="col">
                <div class="slds-truncate" title="Id">Id</div>
            </th>
            <th scope="col">
                <div class="slds-truncate" title="AccountNumber">AccountNumber</div>
            </th>
        </tr>
    </thead>
    <tbody>
        <aura:iteration items="{!v.data}" var="ct">
            <tr>
                <th scope="row" data-label="First Name">
                    <div class="slds-truncate" title="{! ct.Name }">{! ct.Name }</div>
                </th>
                <td data-label="Last Name">
                    <div class="slds-truncate" title="{! ct.Id }">{! ct.Id }</div>
                </td>
                <td data-label="Email">
                    <div class="slds-truncate" title="{! ct.AccountNumber }">{! ct.AccountNumber }</div>
                </td>
                <td>
                <lightning:button name="{!ct.Id}" variant="brand" label="Related_Contacts"  onclick="{! c.showCon }" />
                </td>
            </tr>
        </aura:iteration>
    </tbody>
</table>
</aura:component>


CONTROLLER.JS
________________
({
    doInit : function(component, event, helper) 
    {
    var accRecord = component.get('c.sendAccount');
        accRecord.setParams({
            
        });
        accRecord.setCallback(this,function(response){
            var state = response.getState();
            if(state==='SUCCESS')
            {
                var response = response.getReturnValue();
                console.log(response);
                component.set("v.data" , response);
            }
        });
        $A.enqueueAction(accRecord);
    },

    showCon: function (component, event, helper) 
    {
        var recId = event.getSource().get('v.name');
   var relatedListEvent = $A.get("e.force:navigateToRelatedList"); 
        relatedListEvent.setParams({ "relatedListId": "contact", 
                                    "parentRecordId": recId }); 
        relatedListEvent.fire(); 
        }
    
    });Unfortunately, the related list you're trying to view isn't in the layoutAfter clicking the related contact button this error is shown
Hello,

I am trying to compare the New value in a field which is a string and if it contains 'NO CHANGE' in it, then I would want to replace it by the Old Value. Below is my code. It seems to be not considering Contains expression as it it taking NO CHANGE but not a scentense where NO CHANGE is present. like THIS. HAS NO CHANGE. Below is my code in Before Update

Old Record - This is New 
New Record - this is new - NO CHANGE
Trigger fires and then changes to Old Record - This is New 

 
for(sObject newRecobj: Trigger.new){

myObject__C newRec = (myObject__C) newRecObj;

SObject oldRecObj = Trigger.oldMap.get(newRec.Id);

myObject__C oldRec = (myObject__C) oldRecObj;

if('NO CHANGE'.contains(newRec._NOTE__c) 
    && !string.isBlank(oldRec.NOTE__c) 
&& !'NO CHANGE'.contains(oldRec.NOTE__c)){

                newRec.NOTE__c = oldRec.NOTE__c;
            }

}

What i am I doing wrong here? 
Hi, 
I am using the Workbench SOQL Query tool but am having some issues getting a lookup relationship to work. 

Object: TimecardSplit has a relationship to Project listed within the Fields and Relationships section of the Object Manager.  I have fields from both TimecardSplit and Project that I am trying to pull with the same query.  I've tried subqueries as well as using the dot operator to no avail.  For both the subquery and dot operator methods I have tried using both TimecardSplit and Project as the main object. 

Example of code below, any help would be greatly appreciated.

SELECT Quote_ID__c, pse__Stage__c, pse__Start_Date__c, pse__End_Date__c
(SELECT pse__Billing_Event__c,pse__Total_Billable_Amount__c
FROM pse__Timecard__c )
FROM pse__Proj__c

Thank you!
Matt
I am so close on this one I think. I have built an invocable method to pass two contacts from a flow into Apex to merge the contacts but I am stuck in the part of the code to pass the IDs into the merge command.

Here is the code:

User-added image

The code indicates that there the survivorCont and mergeCont variables do not exist.

I feel like I am very close on this one but could ureally use some help taking this accross the finish line.

Any thought sout there on this one?
Thanks much
Steve
Hello,

I have a related list Quote on page opportunity.
When i click on new i wan that the field lookup(custom) is prefilled with some value.

how can i implement it, thank you for suggestion
  • October 31, 2019
  • Like
  • 0
Trying to create a validation rule that will fire if an active child record (FAR) already exists, (Parent=FA, Child=FAR has Lookup(FA)), and a new child record with the same picklist value is being created.  Following is my validation rule that is preventing creation of any new child record, whether or not one exists already:
AND(
         Active = True,
    OR(
         ISPICKVAL(Role__c,"Joint Approver"),
         ISPICKVAL(Role__c,"Survivor")
        ))
Is there a way to perform a Count of a Role__c record so that the validation rule is looking for a Count > 1? Note that Role__c is a picklist with several values, like Survivor, Joint Approver, and Beneficiary. Only Survivor and Joint Approver values are limited to having only one active child record.
Hi Everyone! I tried searching within the forum and sadly couldn’t find a new solution to my problem (I found a similar issue from a few years ago but the solution was to build a Oneclick Java button and sadly these aren’t support in Lightning).

I would like to add a new button to my related list that creates a new record that is based on the object record type. For example:

Object A record type A: Button creates a new record for Object B record type A

Object A record type B: Button creates a new record for Object B record type B.

It is important that both record types are available for the user so setting a standard record type is not an option. Any suggestions? 
Error: FATAL_ERROR System.QueryException: unexpected token: AZ_lyn_prescription_AZ_JP__c

  global Database.QueryLocator start(Database.BatchableContext BC) {
        
        // Fetch last run from Cutom setting 
        AZM_Settings_AZ_JP__c objSetting = AZM_Settings_AZ_JP__c.getOrgDefaults();
        Datetime lastSync = objSetting.Clear_Suggetsions_Last_Run_time_AZ_JP__c;
        if(lastSync == null ){
            lastSync = System.Now();
        }
        
        String query = 'SELECT Id,AZ_Product_Catalog_AZ_JP__c,AZ_lyn_prescription_AZ_JP__c,AZ_Product_Catalog_AZ_JP__c,Delete_AZ_JP__c,Recordtype.name,Dose_Status_AZ_JP__c,AZ_HCP_AZ_JP__c,CreatedDate,Lastmodifieddate FROM AZ_Patient_Information_AZ_JP__c' + 
                       'WHERE AZ_lyn_prescription_AZ_JP__c = \'Yes\'' +
                       'AND Lastmodifieddate >= '+lastSync.formatGMT('yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'');  
                         System.debug(query);        
                         return Database.getQueryLocator(query);
                         }

Can anyone please help me in this?
COMPONENT
_____________
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="accClass">
   <aura:attribute name="data" type="List"/>
    <aura:attribute name="columns" type="List"/>
    <aura:handler name="init" value="{! this }" action="{! c.doInit }"/>
    <aura:attribute name="id1" type="id" />
    <lightning:navigation aura:id="navigate"/>
    <aura:attribute name="truthy" type="Boolean" Default ="true"/>
   
    <table class="slds-table slds-table--bordered slds-table--cell-buffer">
    <thead>
        <tr class="slds-text-title--caps">
            <th scope="col">
                <div class="slds-truncate" title="Name">Name</div>
            </th>
            <th scope="col">
                <div class="slds-truncate" title="Id">Id</div>
            </th>
            <th scope="col">
                <div class="slds-truncate" title="AccountNumber">AccountNumber</div>
            </th>
        </tr>
    </thead>
    <tbody>
        <aura:iteration items="{!v.data}" var="ct">
            <tr>
                <th scope="row" data-label="First Name">
                    <div class="slds-truncate" title="{! ct.Name }">{! ct.Name }</div>
                </th>
                <td data-label="Last Name">
                    <div class="slds-truncate" title="{! ct.Id }">{! ct.Id }</div>
                </td>
                <td data-label="Email">
                    <div class="slds-truncate" title="{! ct.AccountNumber }">{! ct.AccountNumber }</div>
                </td>
                <td>
                <lightning:button name="{!ct.Id}" variant="brand" label="Related_Contacts"  onclick="{! c.showCon }" />
                </td>
            </tr>
        </aura:iteration>
    </tbody>
</table>
</aura:component>


CONTROLLER.JS
________________
({
    doInit : function(component, event, helper) 
    {
    var accRecord = component.get('c.sendAccount');
        accRecord.setParams({
            
        });
        accRecord.setCallback(this,function(response){
            var state = response.getState();
            if(state==='SUCCESS')
            {
                var response = response.getReturnValue();
                console.log(response);
                component.set("v.data" , response);
            }
        });
        $A.enqueueAction(accRecord);
    },

    showCon: function (component, event, helper) 
    {
        var recId = event.getSource().get('v.name');
   var relatedListEvent = $A.get("e.force:navigateToRelatedList"); 
        relatedListEvent.setParams({ "relatedListId": "contact", 
                                    "parentRecordId": recId }); 
        relatedListEvent.fire(); 
        }
    
    });Unfortunately, the related list you're trying to view isn't in the layoutAfter clicking the related contact button this error is shown
Hello,

I am trying to compare the New value in a field which is a string and if it contains 'NO CHANGE' in it, then I would want to replace it by the Old Value. Below is my code. It seems to be not considering Contains expression as it it taking NO CHANGE but not a scentense where NO CHANGE is present. like THIS. HAS NO CHANGE. Below is my code in Before Update

Old Record - This is New 
New Record - this is new - NO CHANGE
Trigger fires and then changes to Old Record - This is New 

 
for(sObject newRecobj: Trigger.new){

myObject__C newRec = (myObject__C) newRecObj;

SObject oldRecObj = Trigger.oldMap.get(newRec.Id);

myObject__C oldRec = (myObject__C) oldRecObj;

if('NO CHANGE'.contains(newRec._NOTE__c) 
    && !string.isBlank(oldRec.NOTE__c) 
&& !'NO CHANGE'.contains(oldRec.NOTE__c)){

                newRec.NOTE__c = oldRec.NOTE__c;
            }

}

What i am I doing wrong here? 
I realize the benefits of delaritive but where does it stop and have to let code take over?.
Hello Friends,
I have custom button on custom object.
custom object calls VF page and controller.
How i can prevent second click on custom button using checkbox(true or false)
On second it should display error message like
"Cant click for second time".
Pleas help me!
Thank you
Akshata
Dear Team,
I have a process builder flow which simply checks the value of a field and it updates another field in the Account record. 
Oddly, another update process somehow made the FLOW failing so many times that I received the following error message. I don't understand then the connection between the two flows. 

Any suggestions on how to fix it? Oddly this happens quite often when I create processes with Process Builders, but it doesn't happen when I create actual Workflows. 

Thank you.
GC

The flow tried to update these records: null. This error occurred: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: DSCORGPKG.DiscoverOrgCustomMapping_Account: System.LimitException: Apex CPU time limit exceeded. You can look up ExceptionCode values in the SOAP API Developer Guide.---The flow tried to update these records: null. This error occurred: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: DSCORGPKG.DiscoverOrgCustomMapping_Account: System.LimitException: Apex CPU time limit exceeded. You can look up ExceptionCode values in the SOAP API Developer Guide.​​​​​​​

User-added image
 

Hi, i try to test my wrapper class but i have actually 0% coverage.

My wrapper is like :

public class EU01AccountApiWrapper {

    public String code;
    public String name;
    public cls_status status;
    public String website;

...
In my test method i have try to create a wrapper 
EU01AccountApiWrapper wrapper= new EU01AccountApiWrapper();
    wrapper.code = 'Test Wrapper';
    wrapper.name = 'Test Wrapper';


But i have 0%. How can i do ? Ty :)

I was analising a code and came across if(sforce.one){ }, not sure what it does. can someone enlighten me about this
Salesfore Experts, 
 
I am working on a requirement where I need to trigger email with all attachments on a ticket when owner gets changed. The below mentioned code works as expected in Sandbox and I get 87% code coverage but when we try to deploy in production the code coverage is reduced to 25% which I am unable to figure out what is causing it. 
And We are getting error is 
"  ystem.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, zGLOBAL_New_Owner_Notifi_Trigger: execution of BeforeUpdate caused by: System.QueryException: Non-selective query against large object type (more than 200000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times) Class.zGLOBAL_New_Owner_Notifi_Attachment.emailSender: line 9, column 1 Trigger.z  "
 
public class zGLOBAL_New_Owner_Notifi_Attachment  {

public static void emailSender(Map<Id,Case> oldMap, Map<Id,Case> newMap) {
    // this is a list for storing email for settoAddress 
    List<String>toAddress =new List<String>();
    // this is a list for storing email for setccAddress 
    List<String>CCAddress =new List<String>();
    
    List<contact> lstcont=[select id ,Email,name,phone from contact];
    Map<String,String> mapContact=new Map<String,String>();
    list<String> ccAddresslst=new List<String>();
    map<string,String> mapuser=new map<string,string>();    
    Set<Id> accIds=new Set<Id>();
    Set<Id> recId=new Set<Id>();
   
    String ownerName=''; 
    String baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
    
    //for getting user email and store in map where user id is key and email is value
    for(User u:[select id, name, Email from user]) 
    {
        mapuser.put(u.id,u.email);
    }
    
    //for getting Contact name  and store in map where  id is key and name is value
    for(contact con:lstcont)
    {
        mapContact.put(con.id,con.name);
    }
    
    
    //Change Trigger.new with udtCases
    for(Id key : oldMap.keySet())
    {
        case oldcase=oldMap.get(key);
       case cs=newMap.get(key);
        
        if(cs.zGloblal_Total_attachments__c>=1 && cs.APEX_Owner_notifications_Attachments__c==true)
        {
            //Changed Trigger.oldMap
          
            

            if(oldcase.OwnerId!=cs.OwnerId)
            {
               if(string.valueOf(cs.OwnerId).startsWith('005'))
                {
                    toAddress.add(mapuser.get(cs.OwnerId));  
                    ownerName=Getqueuemember.getOwnername(cs.OwnerId);
                }
                
                else{ 
                    CCAddress=Getqueuemember.getEmailfromuser(cs.OwnerId);
                    ownerName=Getqueuemember.getqueueOwnername(cs.OwnerId);
                }
                
                
                List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
                List<Attachment> attlist=[select Name, Body, BodyLength from Attachment where ParentId = :cs.id ];
                for (Attachment a :attlist){
                    
                    Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
                    
                    efa.setFileName(a.Name);
                    efa.setBody(a.Body);
                    fileAttachments.add(efa);
                }
                
                
                String Subject='Ticket #'+cs.CaseNumber+' has been assigned to  '+' '+ownerName;
                
                
                
                try{
                    
                   
                    Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
                    
                    
                    
                    semail.setSubject(Subject); 
                    semail.setSenderDisplayName('Salesforce Support'); 
                    semail.setTargetObjectId(cs.ContactId);
                    //semail.setTemplateId(et.id);
                    semail.setCcAddresses(CCAddress);
                    semail.setToAddresses(toAddress); 
                    
                    semail.setHtmlBody('***THIS IS A SYSTEM GENERATED MESSAGE! DO NOT REPLY!***<br/><br/>Please be advised that the following SalesForce ticket has been assigned to  '+ownerName+'<br/><br/> Ticket #:'+cs.CaseNumber+
                                       '<br/>Subject:'+cs.subject+'<br/><br/>Contact Name: '+mapContact.get(cs.Contactid)+'<br/>Contact Phone (primary): '+Getqueuemember.r(cs.ContactPhone)+'<br/>Contact Mobile (primary): '+Getqueuemember.r(cs.ContactMobile)+
                                       '<br/> Contact Email:'+Getqueuemember.r(cs.ContactEmail)+'<br/><br/>Category: '+Getqueuemember.r(cs.Ticket_Category__c)+Getqueuemember.r(cs.Service_Category__c)+Getqueuemember.r(cs.Ticket_Category2__c)+               
                                       '<br/>Type: '+Getqueuemember.r(cs.Ticket_Type__c)+Getqueuemember.r(cs.Service_Type__c)+Getqueuemember.r(cs.Ticket_Type2__c)+                           
                                       '<br/>Item: '+Getqueuemember.r(cs.Ticket_Item__c)+Getqueuemember.r(cs.Service_Item__c)+Getqueuemember.r(cs.Ticket_Item2__c)+                   
                                       '<br/>Ticket Source: '+Getqueuemember.r(cs.Case_Source__c)+'<br/><br/><br/>Building: '+Getqueuemember.r(cs.building__c)+'<br/>Room: '+Getqueuemember.r(cs.Room_Number__c)+'<br/>Area Description: '+Getqueuemember.r(cs.Area_description__c)+
                                       '<br/><br/><br/>Click the appropriate link below to view the ticket directly:<br/><br/>Partner Portal Users: <a href='+baseUrl+'/'+cs.id+'>'+baseUrl+'/'+cs.id+'</a><br/>BlackbeltHelp (Community Users): <a href='+Getqueuemember.getcommunityurl(cs.AccountId)+cs.id+
                                       '>'+Getqueuemember.getcommunityurl(cs.AccountId)+cs.id+'</a><br/><br/>Description:'+cs.Description+'<br/><br/>Internal Notes: '+Getqueuemember.r(cs.Internal_Notes__c)); 
                    semail.setFileAttachments(fileAttachments);     
                    semail.setWhatId(cs.id);
                 Messaging.sendEmail(new Messaging.SingleEmailMessage[] {semail}); 
                    
                }
                catch(exception e)    
                {}
                
            }
        }
    }
}
}

And Test class is
@isTest
public class zGLOBAL_New_Owner_Notifi_AttachmentTest {
    @isTest
    public Static void emailTest()
    {
       // create test account
        Account acc = TestUtilityController.getAccount('MassBay');
        acc.APEX_Owner_notifications_Attachments__c=true;
        insert acc;
        
        // create test contact
        Contact con = TestUtilityController.getContact('Test Last Name','testing@testing.com',acc.Id);
        insert con;
        
        // fill utility
        UtilityController.fillUtilities();
        UtilityController.isUtility = false;
        
        trigger_control__c tc = new trigger_control__c();
        tc.name='test';
        tc.Enable_Owner_Notification_Trigger__c=true;
        insert tc;
        
        // Create test cases 
        List<Case> listCase = new List<Case>();
        
        if(UtilityController.caseRecordType.containsKey('MassBayCC_Ticket')){
            String recordTypeId = UtilityController.caseRecordType.get('MassBayCC_Ticket').Id;   
                 
             
            Case csanew = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
            csanew.status = 'Action - Automated Escalation';
            csanew.zGloblal_Total_attachments__c=2;
            csanew.Ticket_Category2__c = 'Blackboard Learn - LMS';
            csanew.Ticket_Type2__c = 'Faculty/Staff';
            csanew.Ticket_Item2__c='Tutorial';
            listCase.add(csanew);
            
    //Added additional code here
     System.test.startTest();

            insert listCase;


System.Test.stopTest();

            Getqueuemember.getcommunityurl(acc.id);
            Getqueuemember.getEmailfromuser('0050W0000061RWD');
            Getqueuemember.getOwnername('0050W0000061RWD');
            Getqueuemember.getqueueOwnername('00Gd00000027kH7');
            Getqueuemember.r(csanew.Ticket_Category2__c);
        
    }

}
    
   

}

​​​​​​​

 
Hi, 
I am using the Workbench SOQL Query tool but am having some issues getting a lookup relationship to work. 

Object: TimecardSplit has a relationship to Project listed within the Fields and Relationships section of the Object Manager.  I have fields from both TimecardSplit and Project that I am trying to pull with the same query.  I've tried subqueries as well as using the dot operator to no avail.  For both the subquery and dot operator methods I have tried using both TimecardSplit and Project as the main object. 

Example of code below, any help would be greatly appreciated.

SELECT Quote_ID__c, pse__Stage__c, pse__Start_Date__c, pse__End_Date__c
(SELECT pse__Billing_Event__c,pse__Total_Billable_Amount__c
FROM pse__Timecard__c )
FROM pse__Proj__c

Thank you!
Matt
I am so close on this one I think. I have built an invocable method to pass two contacts from a flow into Apex to merge the contacts but I am stuck in the part of the code to pass the IDs into the merge command.

Here is the code:

User-added image

The code indicates that there the survivorCont and mergeCont variables do not exist.

I feel like I am very close on this one but could ureally use some help taking this accross the finish line.

Any thought sout there on this one?
Thanks much
Steve