• JeffreyStevens
  • SMARTIE
  • 1679 Points
  • Member since 2012
  • Senior Salesforce Develper
  • AutoAlert


  • Chatter
    Feed
  • 45
    Best Answers
  • 1
    Likes Received
  • 62
    Likes Given
  • 55
    Questions
  • 471
    Replies
Hi Everyone,

I'm new to APEX triggers and am trying to use the following guide, https://help.salesforce.com/articleView?id=entitlements_auto_add.htm&type=0, to automatically add entitlements to new cases when created from web mail, email-to-case, and communities. However, when attempting to "Save" the code copied and pasted from the page, I am presented with the error Error: Compile Error: unexpected token: } at line 43 column 0.

I was under the impression that this was due to there being an extre "}" in the code block, so I removed this and received Error: Compile Error: Variable does not exist: contactIds at line 5 column 39
trigger DefaultEntitlement on Case (Before Insert, Before Update) {
    List <EntitlementContact> entlContacts = 
                [Select e.EntitlementId,e.ContactId,e.Entitlement.AssetId 
                From EntitlementContact e
                Where e.ContactId in :contactIds
                And e.Entitlement.EndDate >= Today 
                And e.Entitlement.StartDate <= Today];
        if(entlContacts.isEmpty()==false){
            for(Case c : Trigger.new){
                if(c.EntitlementId == null && c.ContactId != null){
                    for(EntitlementContact ec:entlContacts){
                        if(ec.ContactId==c.ContactId){
                            c.EntitlementId = ec.EntitlementId;
                            if(c.AssetId==null && ec.Entitlement.AssetId!=null)
                                c.AssetId=ec.Entitlement.AssetId;
                            break;
                        }
                    } 
                }
            } 
        } else{
            List <Entitlement> entls = [Select e.StartDate, e.Id, e.EndDate, 
                    e.AccountId, e.AssetId
                    From Entitlement e
                    Where e.AccountId in :acctIds And e.EndDate >= Today 
                    And e.StartDate <= Today];
            if(entls.isEmpty()==false){
                for(Case c : Trigger.new){
                    if(c.EntitlementId == null && c.AccountId != null){
                        for(Entitlement e:entls){
                            if(e.AccountId==c.AccountId){
                                c.EntitlementId = e.Id;
                                if(c.AssetId==null && e.AssetId!=null)
                                    c.AssetId=e.AssetId;
                                break;
                            }
                        } 
                    }
                } 
            }
        }
    } 
}
Thanks in advance, everyone. 
 
I am struggling to write the test class for a trigger that updates a custom lead field (date_demo_scheduled_for__c) based on the ActivityDate when an event is created. The following is the apex trigger which works in the sandbox and below that is what I have for the test class. Any insight would be greatly appreciated! I am a total newbie with apex currently.
TRIGGER:

Trigger DemoEvent on Event (after insert,after update) {
Event[] eventList;
eventList = trigger.new;
for (Event e:eventList) {
String leadId = e.WhoId;
if (e.WhoId!=null) {
Lead l = [SELECT Date_Demo_Scheduled_For__c FROM Lead WHERE Id = :leadId]; {
l.Date_Demo_Scheduled_For__c = e.ActivityDate;
} update l;
}
}
}

TEST CLASS:
@isTest
private class DemoEventTest {
    static testMethod void leadFix() {
       Lead b = new Lead (Name= 'DemoEventTest', Company='Grow.com', Date_Demo_Scheduled_For__c= '2016-11-02', Date_Demo_Given__c= '2016-10-15', Source__c='LinkedIn', Medium__c='Mined Sales', Campaign__c='No Data', Request__c='No Data');
       // Insert Lead
       insert b;
      // Insert Event
      Event evnt = new Event( Name = 'Test Event', ActivityDate = '2016-10-31');
                        insert event;
       // Retrieve the new Lead
       b = [SELECT Date_Demo_Scheduled_For__c FROM Lead WHERE Id =:b.Id];
       // Test that the trigger correctly updated the date demo scheduled for
    }
}
I am trying to display images on Vf page which i am able to but I want to display images horizantally on my VF page.

below is my VF page code which now displays images vertically.
 
<apex:page standardController="Account" extensions="AccountController" showHeader="false" sidebar="false" standardStylesheets="false">
    <table class="detailList" border="0" cellpadding="0" cellspacing="5">
        <apex:repeat value="{!Images}" var="I">
            <tr>
                <td><image src="{!I.url}" alt="{!I.name}"/></td>
            </tr>
        </apex:repeat>
    </table>
</apex:page>

 

Hi, guys.
i´d like to retrieve a information from a list that i made a sub querie.

Following controller with the visualforce page
 
public TesteGuiasList(){
        //Instancias construtor
        this.insumosList = new List<INSUMO__c>();
        this.complGuiaList = new List<GUIA_SOLIC_COMPL__c>();
    }
    
    public List<INSUMO__c> getInsumosList(){
      
        insumosList = [select Name,COD_TUSS_DEFINITIVO__c,(Select COD_DISTRIBUIDOR__c from Insumos_Aprovados__r),
                       (select Name,QTD_AUTORIZADA__c,QTD_UTILIZ_PREST__c,QTD_LIBERADA_AUDIT__c,QTD_UTILIZ_INTERM__c from ITENS_GUIA__r) 
                       from INSUMO__c ];
       
        return insumosList;
    }


now following the VF page
 
<apex:pageBlockSection title="INSUMOS" columns="1" collapsible="false"  id="pageBlockSectionOpme">
            <apex:pageBlockTable value="{!insumosList}" var="insumos" id="tbOpme">
                
                <apex:column value="{!insumos.Name}" />
                <apex:column value="{!insumos.COD_TUSS_DEFINITIVO__c}" /> 
                <apex:column value="{!insumos.COD_DISTRIBUIDOR__c}" />  
                
                
            </apex:pageBlockTable>
            
        </apex:pageBlockSection>


I want to show insumos.COD_DISTRIBUIDOR__c in the same colunm, and shows me the following error:   Invalid field COD_DISTRIBUIDOR__c for SObject INSUMO__c


I know what that means, but how to show a field i query on my controller and is not working in my VF.  
 
PS; If my question get confused or you need more information, please let me know!
 
Thnak´s folks!
I have a Visualforce page with a table and would like to add color to my cells and in some cases to my entire row. I don't know what the syntax is to insert the color and what it is I need to insert and where in my table to indicate that I want a particular color either for a cell or for the entire row. Cna someone help me by posting the syntax in the exact format opening and closing statements that I must include for this to go through? Perhaps include a sample color that I could test out.
 
General question: Standard Salesforce pages provide the ability to resequence a form's contents when a header is clicked (once for ascending, a second time for descending). when buildin a Visualforce page, what is the code used to provide that resequencing functionality? I would think it would be an addition to the columnHeader value portion of the apex code, but I can not find the specific coding. Something that would fit inside:
<apex:column headerValue="Property Name">
      <apex:outputLink value="/{!mp['Id']}" title="{!mp['Name']}" target="_top">{!mp['Name']}
      </apex:outputLink>
</apex:column>

Any ideas?

A consultant wrote a Opportunity Trigger but no code coverage. Any help with developing a test class would be appreciated, so I could deploy the Trigger below to production.

trigger Opp_Trigger on Opportunity (after insert, after update) {
    
    
    if ((!Util.DoNotRunTrigger) && (Trigger.IsAfter) && (!Archtics.HasSentArchticsCreate))
    {
        /* create in Archtics */
        set<Id> accids = new set<Id>();
        set<Id> ownerids = new set<Id>();
        
        for (Opportunity o : Trigger.new)
        {
            Opportunity oldopp;
            if (Trigger.IsUpdate) oldopp = Trigger.oldmap.get(o.Id);
            
            accids.add(o.AccountId);
            ownerids.add(o.OwnerId);
        } 
        
        map<Id, Account> accid2accmap = new map<Id, Account>();
        if (accids.size() > 0)
        {
            accid2accmap = new map<Id, Account>([select Id, 
                Update_in_Archtics_Wizards__c, Update_in_Archtics_Mystics__c, 
                Update_in_Archtics_Capitals__c, Update_in_Archtics_MSE__c,
                Create_in_Archtics_Wizards__c, Create_in_Archtics_Mystics__c, 
                Create_in_Archtics_Capitals__c,Create_in_Archtics_MSE__c, 
                Acct_Rep_ID_Capitals__c, Acct_Rep_ID_Mystics__c, Acct_Rep_ID_Wizards__c,
                Archtics_ID_Wizards__c, Archtics_ID_Mystics__c, Archtics_ID_Caps__c,Archtics_ID_MSE__c
                from Account
                where Id in :accids]);
        }
        
        map<Id, User> userid2usermap = new map<Id, User>();
        if (ownerids.size() > 0)
        {
            userid2usermap = new map<Id, User>([
                select Id, Archtics_Rep_ID_Wiz__c, Archtics_Rep_ID_Mystics__c, Archtics_Rep_ID_Caps__c
                from User
                where Id in :ownerids]);
        }
        
       // set<Id> capitalsaccids = new set<Id>();
        //set<Id> mysticsaccids = new set<Id>();
    //  set<Id> wizardsaccids = new set<Id>();
        set<Id> MSEaccids = new set<Id>();
        
        for (Opportunity o : Trigger.new)
        {
            if ((!o.Name.contains('Auto-created Opportunity'))
                && (o.Product_Category__c != null))
            {
                if (o.Product_Category__c.contains('Caps'))
                {
system.debug('\n\n42 caps found');          
                    Account thisacc = accid2accmap.get(o.AccountID);
                    
                    if (   (thisacc != null)
                           && (thisacc.Archtics_ID_MSE__c == null)
                           && ( (o.StageName=='Completed Sale') || (o.StageName=='Hot') || (o.StageName=='Comp Requested') )    
                        )
                    {
                        thisacc.Acct_Rep_ID_Capitals__c = userid2usermap.get(o.OwnerId).Archtics_Rep_ID_Caps__c;
                        accid2accmap.put(o.AccountId, thisacc);
                        //capitalsaccids.add(o.AccountId);
//                      thisacc.Acct_Rep_ID_MSE__c = userid2usermap.get(o.OwnerId).Archtics_Rep_ID_MSE__c;
                        MSEaccids.add(o.AccountId);
                    }
                }
                if ((o.Product_Category__c.contains('Wizards') || (o.Product_Category__c.contains('Valor')
                    || (o.Product_Category__c.contains('Family Shows/Events and Concerts')))))
                {
                
                    Account thisacc = accid2accmap.get(o.AccountID);
                    
                    if ((thisacc != null)
                        && (thisacc.Archtics_ID_MSE__c == null)
                        && ( (o.StageName=='Completed Sale') || (o.StageName=='Hot') || (o.StageName=='Comp Requested') )
                        ) 
                    {
                        thisacc.Acct_Rep_ID_Wizards__c = userid2usermap.get(o.OwnerId).Archtics_Rep_ID_Wiz__c;
                        accid2accmap.put(o.AccountId, thisacc);
                        MSEaccids.add(o.AccountId);
                    }
                }
                if (o.Product_Category__c.contains('Mystics'))
                {
                    Account thisacc = accid2accmap.get(o.AccountID);
                    
                    if ((thisacc != null)
                        && (thisacc.Archtics_ID_MSE__c == null)
                        && ( (o.StageName=='Completed Sale') || (o.StageName=='Hot') ||(o.StageName=='Comp Requested') )
                        )
                    {
                        thisacc.Acct_Rep_ID_Mystics__c = userid2usermap.get(o.OwnerId).Archtics_Rep_ID_Mystics__c;
                        accid2accmap.put(o.AccountId, thisacc);
                        MSEaccids.add(o.AccountId); // mystics now created in MSE as well
                    }
                }
            }
        }
        
        if (accid2accmap.size() > 0)
            update accid2accmap.values();
        
        //if (capitalsaccids.size() > 0)
            //Archtics.createFuture(capitalsaccids, 'Capitals');
        //if (wizardsaccids.size() > 0)
            //Archtics.createFuture(wizardsaccids, 'Wizards');
         
        //changed from wizardsaccids to MSEaccids 130711 JN
        if (MSEaccids.size() > 0)
            Archtics.createAccountsInArchtics(MSEaccids, 'MSE');
        Archtics.HasSentArchticsCreate = TRUE;
    } //end if IsAfter
}
Hello. I'm new to Apex and am looking for some advice regarding working with data and avoiding governor limits.

Here's what I'd like to accomplish:

1. Perform a SOQL query and grab some data from Contacts (roughly 500 records in total). The 500 records will be owned by 10 people.
2. With that data in hand further divide that data into groups sorted by ownerid. For example if 50 records are owned by ownerid = 'abc' I want to somehow be able to process those 50 records
3. In this scenario processing consists of emailing out a message to the email address associated with the ownerid
3. Once the email is sent move on to the next set of records owned by the next ownerid

I'd like to schedule this to run once a day.

I was thinking I could use a map with the ownerid as the key and a Contact sObject List as the values. 

However not sure if this is something that can be scheduled???

Any help would be greatly appreciated!

Thanks,

Mike
Hi All,

I am trying to show the user Profile Picture of Salesforce in Visualforce email template by using <apex:image url="{!relatedTo.LastModifiedBy.smallphotourl} /> . But when I send email then in place of Image I see  'X' in vf Template.

Then I took help of below link :
https://help.salesforce.com/HTViewSolution?id=000003730&language=en_US

So according to this link it is not possible. But is it possible to show that images with a programatically approach ?
 
Hello!

I apologize if I am placing this query in the wrong topic, but I believe that this is where it should be!  

I am attempting to make a (somewhat) simple app for my technicians that they can access via the SalesForce1 App.  Basically it will be a tab labelled 'Check In' that the technician presses which will give the tech a few different options that they can set as their status and will then link to a visual force page that collects the techs location data via geocaching and then outputs this location data along with the status the tech seleccted with a timestamp to a 'current location' and 'current status' field in the 'technician' object.  A dashboard will then collect this data and display on the salesforce main screen so that we always know our techs status and location.

Is this possible?  Am I way off track?  I'm fairly new to Salesforce so even just some help getting pointed in the right direction would be greatly appreciated!
Hi,

I'm trying to execute a piece of apex code in workbench and 
system.debug('a || b');

is printing
a &#124;&#124; b instead of a || b

Any idea how to retain |.

I tried escaping but escaping | with backslash \| is not permitted.

Background: I'm trying tooling api to create a VF page at runtime. My VF page has a logical OR condition and I was hoping to use a cleaner OR conditions instead of negatory AND conditions.
I am new to apex coding, and I working on a pro-bono project for a non-profit. I am having a problem writing a working test for an apex class and VF page combination that I truly believe is working as intended (tested in Sandbox - not verified by apex test class). I was hoping someone could help me clean up this test class so that I can get this function deployed.  

Here's what I have so far - 

VF Page:

<apex:page controller="AddMultipleAttendanceController" >
    
    <apex:form >
    
    <apex:pageBlock >
    
        <apex:pageBlockTable value="{!listAttendances}" var="Att">
        
            <apex:column headerValue="Client">
                <apex:inputField value="{!Att.Client__c}"/>
            </apex:column>
        
            <apex:column headerValue="Program Name">
                <apex:inputField value="{!Att.Program__c}"/>
            </apex:column>

            <apex:column headerValue="Session Week">
                <apex:inputField value="{!Att.Session__c}"/>
            </apex:column>
      
        </apex:pageBlockTable>

    <apex:pageBlockButtons >
    
        <apex:commandButton value="Add Attendances Row" action="{!addAttendance}"/>

        <apex:commandButton value="Save Attendances" action="{!saveAttendance}"/>

    </apex:pageBlockButtons>

    </apex:pageBlock>
    
</apex:form>
</apex:page>


Here is the Apex Class:

public class AddMultipleAttendanceController
{   
    Attendance__c enrollment = new Attendance__c();
     
    public List<Attendance__c> listAttendances { get; set; } 
         
    public AddMultipleAttendanceController()
    {
    listAttendances= new list<Attendance__c>();
    listAttendances.add(enrollment);
    }
    
    Public void addAttendance()
    {
    Attendance__c Att = new Attendance__c();
    listAttendances.add(Att);
    }
    public PageReference saveAttendance() {
    for(Integer i=0; i<listAttendances.size(); i++)
    {
    insert listAttendances;
    }
    return Page.Allitemssaved;
    }   
}

I cannot manage, however, to get a test class to work. I was planning on just using a single object item to test it, but maybe that wasn't working. Can anyone help me with this?

Here is all that I have managed to code for the test class (like I said, novice):

@isTest
public class AddMultipleAttendanceControllerTests {

    Private Static testmethod void AddMulitipleAttendanceControllerTests() {
        Attendance__c objAttendance = new Attendance__c();
        objAttendance.Client__c = 'a0v5B000000AHni';
        objAttendance.Program__c = 'a105B00000002j9';
        objAttendance.Session__c = 'a135B0000000MwN';
        insert objAttendance;

I would really appreciate any help with this. I'm sure there are people out there that could do this in just a few moments, but I lack the skill. Any documentation that you could add explaining the steps that I am missing would be extremely helpful. Thanks.

 

Here is a simple trigger. There are two objects with look ups to one another, Project and Opportunity.
Goal here is that when a Project is created with a lookup populated to Opportunity, that the code goes out to that Opportunity and populates the lookup withe the id to the project. This should work on create/change and if the lookup on Project is nulled out, that the lookup that may have exited pointing back to it from Opportunity is also nulled.

The code is working in the first instance (when a project is created, it finds the opp and fills out the lookup) but it is not doing any actions on 'update' (nulling or updating) which is confusing me given the simplicty of the code.

Thoughts?

 

trigger PSA_Project_Automation on pse__Proj__c (before insert, before update) {
List<Id> OpportunityIds = new List<Id>();
List<Id> NullOpportunityIds = new List<Id>();   
    for (pse__Proj__c proj : Trigger.new){
       
            if(proj.pse__Opportunity__c != null){
            OpportunityIds.add(proj.pse__Opportunity__c);
            }  
           
        if(Trigger.IsUpdate){
            pse__Proj__c oldProj = Trigger.oldMap.get(proj.Id);
            
            if(proj.pse__Opportunity__c == null && oldProj.pse__Opportunity__c !=null)
             NullOpportunityIds.add(oldProj.pse__Opportunity__c); 
        }
        
    }

    List<Opportunity> oppList = [SELECT id, pse__Primary_Project__c FROM Opportunity Where id in :OpportunityIds];
    List<Opportunity> NullOppList = [SELECT id, pse__Primary_Project__c FROM Opportunity Where id in :NullOpportunityIds];
    
    for(pse__Proj__c p : Trigger.new){
    for(integer i=0; i<oppList.size(); i++){
      oppList[i].pse__Primary_Project__c = p.id;
        }
    for(integer i=0; i<NullOppList.size(); i++){
      NullOppList[i].pse__Primary_Project__c = null;      
        }
    }
Hi,

While going through the code of one of the class in my project I found that PriceBookEntry object is used. However when I tried to find it in setup/object menu I couldn't find. But I can find this object in eclipse as PricebookEntry.object.

Can anyone please let me know how I can find it in setup.

Arun.
Hi All,

I need to create a trigger that "rolls up" the field Amount__c from a custom object Sessions to a custom object called Session_Invoice to a field called Invoice_Amount - I can't use a rollup summary field unfortunately as it's just a lookup relationship.

I'm quite new to Salesforce and Coding, so struggling where to start!

Any help would be much appreciated
 
trigger SessionAmountRollup on Session__c (after insert, after update, after delete, after undelete) {
  
}

 
Hello,

I have what I think is a very simple request, but I'm struggling with it.  I have a custom field on the Case object called Account ID, which is a text field.  I also have a field called Primary Account, which is a lookup field.  I have a Google form integration that creates a Case when a form is submitted and populates the Account ID with the 15-character Account ID, input by the form submitter.  I want to create a trigger to take that value and populate the Primary Account lookup field with the Account associated with the ID.  Can anyone point me to code that can accomplish this?  Thanks,

What I want to do is pull a list of events scheduled for today but only list the events relevant to the active user.... Here's what I have so far...

 

public class QuickLogController {
    public String username{get;set;}
    
    public string finduser(){
		
        username = Userinfo.getUserName();
        return username;
    }  
    
    public list<event> getEventsToday(){
       
       List<event> TodaysEvents = Database.query (
           'SELECT Who.Name, Owner.id, Subject, StartDateTime, Location FROM event WHERE StartDateTime = TODAY AND Owner.Name = :username ');
        return TodaysEvents;
        	        
    }
    
}

When I run this without "AND Owner.Name = :username '" it works fine.  When I test it in the query editor and replace ":username" with my name, it works fine.  Not sure what I'm doing wrong here?
Hi All,

  when to use nested list in salesforce
  can you please help understnd following list, adding data, iterating data for the follwing example
  List<List<list<Integer>>> my_list_2 = new List<List<list<Integer>>>();
  explain me to  nexted complete playing with any example please
I have run into a myriad of issues with process builder and have decided to build a trigger.

LLC_BI__Loan__c is the 'Parent'
LLC_BI__Loan_Collateral2__c is the 'Child'

I wanted to update the Stage_Number__c field on the child record with a number based on the stage of the parent when a stage is changed.  

trigger LoanStageNumberUpdate on LLC_BI__Loan__c (after update) {
 
 for(LLC_BI__Loan__c loan: Trigger.new){
  LLC_BI__Loan__c oldloan = Trigger.oldMap.get(loan.Id);
  if(oldloan.LLC_BI__Stage__c != loan.LLC_BI__Stage__c)
   { 
    List<LLC_BI__Loan_Collateral2__c> collateral = [ SELECT Id, LLC_BI__Loan__c FROM LLC_BI__Loan_Collateral2__c WHERE LLC_BI__Loan__c = :loan.Id];
    List<LLC_BI__Loan_Collateral2__c> newcollateral = new List<LLC_BI__Loan_Collateral2__c>();
 
    for(LLC_BI__Loan_Collateral2__c col: collateral)
    {
        if(loan.LLC_BI__Stage__c == 'Pre-Underwriting'){col.Stage_Number__c = 1;}
            else if(loan.LLC_BI__Stage__c == 'Underwriting'){col.Stage_Number__c = 2;}
              else if(loan.LLC_BI__Stage__c == 'Credit Decision'){col.Stage_Number__c = 3;}   
                  else if(loan.LLC_BI__Stage__c == 'Client Decision'){col.Stage_Number__c = 4;}   
                      else if(loan.LLC_BI__Stage__c == 'Pre-Closing'){col.Stage_Number__c = 5;}   
                          else if(loan.LLC_BI__Stage__c == 'Doc Prep'){col.Stage_Number__c = 6;}  
                              else if(loan.LLC_BI__Stage__c == 'Doc Review'){col.Stage_Number__c = 7;}  
                                  else if(loan.LLC_BI__Stage__c == 'Post-Closing'){col.Stage_Number__c = 8;}   
                                      else if(loan.LLC_BI__Stage__c == 'Funding/Booking'){col.Stage_Number__c = 9;}   
    }
           {
       if (newcollateral.isEmpty() == false){
       update newcollateral;
      }
    }
  }
}
}
Hello, 

I am trying to avoid my team creating duplicate accounts by spelling account names incorrectly (i.e. ACME, ACEM, ACME LTD etc).

what I was thinking of doing was creating a custom field on the account level similar to email (spara@acme.com) and comparing that bolded portion to account names, and having an error message saying this account may already exist.

Is there a way to code that, or maybe even an easier way?
How is the IN clause used with a set<> in batch and getQueryLocator?
 
I have this code:
 
// (in the Start method of a batch class....)  
set<id> accountIDs = new set<id>(); // This is already populated... 
queryString = 'SELECT id,name FROM Account WHERE id IN :accountIDs'; 
return Database.getQueryLocator(queryString);

Is this the correct syntax?  How do you actually use a set<> (or .keyset() from a map) in a queryString that get's passed to the getQueryLocator?
I'm using the ConnectAPI to create a chatter message in APEX, and in the MentionSegmentInput class - I'm setting the the ID of the user that get's mention (mentionSegmentInput.id = ...).  But I don't know how to set the ID of the user that chatter is from?  (right now - it's coming from me - and I want to set it to another user).
 
Anybody know where to look for that?
When Chat (formerly Live Agent) is used to create a case - is there a way that I can set the status (field = Status) on the case to "Working".  I've been searching the embedded_svc.settings script - but haven't found if it's possible. Thanks!
So - I always get this error in VSCode - whenever I try to do of the SFDX commands...

Unexpected file found in package directory: /.../Icon

I've been using VSCode for several months now, and I've always got around this error by just going into every folder in the project and deleting the file "Icon".  But I'd like to find the root cause and fix it.

Anytime I build a new project - it will be a file canned "Icon" in every folder of the project.  Deleting the file takes care of the error - but now that I'm using more scratch org's and building more projects - it's becoming quite a bother.

Thoughts?

 
I'm working on some more LWC learning - trying to understand how a custom wrapper class is displayed in the component.

If I have this APEX, .js, and HTML - the value of field1 is never displayed - can anyone see my issue?

Thanks!

APEX:
@AuraEnabled(cacheable=true)
	public static wrapperClass  rtnWrapperClass(){
		wrapperClass wrapper = new wrapperClass();
		wrapper.field1 = 'Value for field1';
		wrapper.field2 = 'Value for field2';
		return wrapper;
	}

	public class wrapperClass {
		@AuraEnabled 	public string  	field1		{get;set;}
		@AuraEnabled 	public string 	field2		{get;set;}
		public wrapperClass() {
			this.field1 = field1;
			this.field2 = field2;
		}
	}
.js
import rtnWrapperClass from '@salesforce/apex/HelperAccount.rtnWrapperClass';

export default class showWrapper extends LightningElement {

    // Return  Wrapper Class
    @wire(rtnWrapperClass)
        wrapperClass;

}

and the HTML:
<!-- Data from Wrapper Class -->
            <p>Wrapper Class Data...</p>
            <template if:true={wrapperClass.data}>
                <lightning-formatted-text
                    value={wrapperClass.field1}>
                </lightning-formatted-text>
            </template>



 
I have a LWC that is returning an sObject from APEX.  How do you display a field in the HTML?

my .js has...
import rtnSObjectRec from '@salesforce/apex/HelperAccount.rtnSObjectRec';

The APEX is:
@AuraEnabled (cacheable=true) 
	public static Account rtnSObjectRec(string recId) {
		Account sObjectRec = [SELECT id,name FROM Account WHERE Id = :recId];
		return sObjectRec;
	}

The HTML is:
<lightning-formatted-text value={sObjectRec.name.data}></lightning-formatted-text>

But the LWC doesn't display.  If I change the HTML to
<lightning-formatted-text value="testData"></lightning-formatted-text>
The lwc will display, and the "testData" will show.

Can anybody see what I'm doing wrong?

Thanks,

(I know I can just use the data service to get sObjects, I'm just trying to understand the syntax on the HTML side. Eventually, I want my APEX to return a custom sub-class)


 

I have a lightning web component that uses @wire to call to APEX. It works just fine when I place the component on a lightning page and display from a Salesforce user. However, the APEX never get's called when I place the component on a Community page.
Is there a setting that needs to be done to allow access from a community?
Thanks,
So, I have a lightning web component that calls an APEX method to return something.  When I try to display what the APEX returns, I always get [object Object] in the html.

Here's the code:
//.js....
import { LightningElement, api, wire } from 'lwc';
import acceptRtnSomthing from '@salesforce/apex/HelperAccount.acceptRtnSomthing';

export default class UltimateParentMRR extends LightningElement {
    @api recordId;
    somethingReturned = "Value in .js....";
    
    @wire(acceptRtnSomthing, {recId : '$recordId' })
        somethingReturned;

}




// HTML....
<template>
    <lightning-card title="Ultimate Parent MRR" icon-name="standard:account">
        <div class="slds-m-around_medium">
            {somethingReturned}
        </div>
    </lightning-card>
</template>


// APEX...
@AuraEnabled (cacheable=true)
	public static string acceptRtnSomthing(string recId){
		return recId;
	}
If I comment out the call to the APEX - I get "Value in .js...." in the HTML output.

Does anybody see my issue?

Thanks!
 
I'm trying to call the Amazon S3 API from Apex, but keep getting a

System.HttpResponse[Status=Forbidden, StatusCode=403] error. 

I know my end-points, key and secret are correct - as I pasted them directly from a working Postman example.

Can anyone see issues with my code?

Thanks!
 
public  list<string> rtnBucketItems(string bucketName, string key, string secret) {
		if(bucketName==null) 	bucketName 	= '******************************';
		if(key==null) 			key 		= '******************************';
		if(secret==null)		secret		= '******************************';

		String currentTimestamp = datetime.now().formatGmt('EEE, dd MMM yyyy HH:mm:ss Z');

		list<string> bucketItems = new list<string>();

		Http http = new Http();
		HttpRequest request = new HttpRequest();
		request.setMethod('GET');
		request.setHeader('Host','******************************.s3.amazonaws.com');
		request.setHeader('Content-Encoding', 'base64');
		request.setHeader('Date',currentTimestamp);
		request.setEndpoint('https://******************************.s3.amazonaws.com');

		// Build and set Authorization Header
		string stringToSign = 'GET\n\n\n' + currentTimestamp + '\n\n/' + bucketName;
		string stringSigned = rtnSignedString(stringToSign, secret);
		string authHeader = 'AWS' + ' ' + key + ':' + stringSigned;
		request.setHeader('Authorization', authHeader);

		HttpResponse response = http.send(request);
		system.debug('response='+response);

		return bucketItems;
	}


	public string rtnSignedString(string inString, string secret) {
		string signedString;
		Blob mac = Crypto.generateMac('HMACSHA1',blob.valueOf(inString),blob.valueOf(secret));
		signedString = EncodingUtil.base64Encode(mac);
		return signedString;
	}



 
In classic - on Events - there is an "Export Event" button.  It's a JS to /servlet/servlet.outlookEvent?....

Does anybody know of a replacement / work-around for this functionality in Lightning?
Has anybody noticed Spring 19 Saves being very slow?  I've verified the slowness in MM/Sublime, Eclipse, and Dev console.  It's intermentient, sometimes it saves in less than 1 minute, but many times - it's 5+ minutes for a souce code save.  I've verified it on multiple internet connections, and different userIDs, and MacOS and Windows.
I have a string that is end of line dilimited with the paragraph (or pilcrow), (ascii 0182).

Does anybody know the character to split on? 

ie for a New+Line dilimited it's ...
list<string> lines = fullText.split('\n');

But for the paragraph - I can't seem to find the right character.
I'm getting ready to add a community, however, I'm concerned if enabling Communities has anything to do with My-Domain?  If I setup a community - do I have to enable My-Domain?  I have some external integrations that i'm sure are using my node isntance (ie NA56.salesforce.com)  in integrations, and I'm not ready to implement My-Domain yet.

Should I be concerned about setting up a Community with regard to not being ready to implement My-Domain?
I have a lightning component that I'm putting on a Community page, and I want to place a download link on it - to download an attachment.

In Visualforce - I always did...
<apex:image value="/servlet/servlet.FileDownload?file={!attachmentId}"  />Download</apex:image>

So, in the markup of the component, I've tried
<a href="{!'/servlet/servlet.FileDownload?file=00P4D000000Oub6'}">Download</a>

But when I do this, and click on the link - it just's takes me to a Site is in Maintenance message. 

Has anybody done a download link of an attachment ID in a componet?

Thanks
After completing the trailhead for Lightning components, I'm trying one  in my sandbox now.   I'm missing something, and maybe it's my Attribute in the Component, but I'm not sure?  My output doesn't produce the {!v.Transactions[0].name} field (just the "[Transactions List...]".

Component
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global" controller="ctrl_TransactionList">
   
    <aura:handler name="init" action="{!c.doInit}" value="{!this}" />
    
    <div class="slds-page-header" role="banner">
    	<div class="slds-grid">
        	<div class="slds-col">
   				[Transactions List...]<br/>
                <ui:outputText value="{!v.Transactions[0].name}" /> 
            </div>
        </div>
    </div>
    
</aura:component>
Componenet Controller
({
	doInit: function(component, event, helper) {
		console.log('doInit...'); 
        
       
        var action = component.get("c.getTransactions");
        
        action.setCallback(this, function(response) {
            var state = response.getState();
            if(component.isValid() && state === "SUCCESS") {
                component.set("v.items", response.getReturnValue());
            } else {
                console.log("Failed with state: " + state);
            }
        });
        
        $A.enqueueAction(action);
	},
})

Apex Controller
public without sharing class ctrl_TransactionList {
    
    @AuraEnabled
    public static list<Transaction__c> getTransactions() {
        return [SELECT id,name,Payee__r.Name FROM Transaction__c WHERE id = 'a0T2A00000LDUQf'];
    }

}


 
I've read through several posts on the Connect Components with Events challenge, and I'm still not seeing what's wrong with my campingListController.  I'm getting the Challenge Not yet complete message. "The campingList JavaScript controller isn't setting the 'item' as a parameter or saving the record correctly"

Can anybody tell me where I'm wrong?

campingList - component
<aura:component controller="CampingListController">
    
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
   
    <aura:handler name="addItem" event="c:addItemEvent" action="{!c.handleAddItem}"/>
    
    <div class="slds-page-header" role="banner">
      <div class="slds-grid">
        <div class="slds-col">
          <p class="slds-text-heading--label">Camping Items</p>
          <h1 class="slds-text-heading--medium">My Camping Items</h1>
        </div>
      </div>
    </div>

      
  	<div aria-labelledby="newitemform">
      <fieldset class="slds-box slds-theme--default slds-container--small">   
        <c:campingListForm />
      </fieldset>
	</div>
    
    
     <aura:attribute name="items" type="Camping_Item__c[]"/>

    <div class="slds-card slds-p-top--medium">
        <header class="slds-card__header">
            <h3 class="slds-text-heading--small">Camping List Items</h3>
        </header>
        
        <section class="slds-card__body">
            <div id="list" class="row">
                <aura:iteration items="{!v.items}" var="campItem">
                    <c:campingListItem item="{!campItem}"/>
                </aura:iteration>
            </div>
        </section>
    </div>

</aura:component>

campingList - Controller
({

    //
    //      Load Camping Items at startup
    //
    doInit: function(component, event, helper) {
        // Create the action
        var action = component.get("c.getItems");

        // Add callback behavior for when response is received
        action.setCallback(this, function(response) {
            var state = response.getState();
            if(component.isValid() && state === "SUCCESS") {
                component.set("v.items", response.getReturnValue());
            } else {
                console.log("Failed with state: " + state);
            }
        });

        // Send action to be executed
        $A.enqueueAction(action);
    },

    handleAddItem: function(component, event, helper) {
    	var item = event.getParam("item");
      	var action = component.get("c.saveItem");
      	action.setParms({"item" : item});
        action.setCallback(this,function(response){
           	var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                var items = component.get("v.items");
                items.push(response.getReturnValue());
                component.set("v.items", items);
            }
        });
        $A.enqueueAction(action);
    },

	
})

Nothing in the helper.

Thanks!
 
I'm working through the Connect to Salesforce with Server-Side Controllers step, and before the challenge - dealing with the expenses - my createExpense function is getting a response state of ERROR.  I am NOT getting anything in the debug on the apex controller that it's even being called.

Can anyone give me some more to go on here?

expensesHelper.js...
({
    validateExpenseForm: function(component) {
    	
        var validExpense = true;
        
        // Name must not be blank
        var nameField = component.find("expname");
        var expname = nameField.get("v.value");
        if ($A.util.isEmpty(expname)) {
            validExpense = false;
            nameField.set("v.errors", [{message: "Expense name can't be blank."}]);
        } else {
            nameField.set("v.errors", null);
        }
        
        // Amount must be set
        var amtField = component.find("amount");
        var amt = amtField.get("v.value");
        if ($A.util.isEmpty(amt) || isNaN(amt) || (amt <= 0.00)) {
            validExpense = false;
            amtField.set("v.errors", [{message:"Enter an expense amount."}]);
        } else {
            amtField.set("v.errors", null);
        }
        
        return validExpense;
        
    },
    
	createExpense : function(component, expense) {
        console.log('createExpense...');
        
        var action = component.get("c.saveExpense");
        action.setParams({"expense" : expense});
        
        action.setCallback(this, function(response) {
        	var state = response.getState();
            console.log('response='+response + response.getState());
            if (component.isValid() && state === "SUCCESS") {
                var expenses = component.get("v.expenses");
                expenses.push(response.getReturnValue());
                component.set("v.expenses", expenses);
            }
        });
        $A.enqueueAction(action);
        var theExpenses = component.get("v.expenses");
		console.log("theExpenses="+JSON.parse(JSON.stringify(theExpenses)));
	}
})

ExpenseController.apxc...
public with sharing class ExpenseController {
    
    @AuraEnabled
    public static list<Expense__c> getExpenses(){
        system.debug('getExpenses...');
        // Perform isAccessible() checking first, then
        // check to make sure all fields are accessible to this user
        
        String[] fieldsToCheck = new string[] {
            'Id', 'Name', 'Amount__c', 'Client__c', 'Date__c', 'Reimbursed__c', 'CreatedDate'
        };
        map<string,Schema.sObjectField> fieldDescribeTokens = Schema.sObjectType.Expense__c.fields.getMap();
        
        for(String field :fieldsToCheck) {
            if (!fieldDescribeTokens.get(field).getDescribe().isAccessible()) {
                throw new System.NoAccessException();
                return null;
            }
        }

        
        return [SELECT id,name, Amount__c, Client__c, 
                		Date__c, Reimbursed__c,CreatedDate
               	FROM Expense__c];
    }

    @AuraEnabled
    public static Expense__c saveExpense(Expense__c expense) {
        system.debug('saveExpense...');
        // Perform isUpdateable() checking first, then
        upsert expense;
        system.debug('expense='+expense);
        return expense;
    }
}

 
Can I change the ownerID of an Account record to a customer community user?

The standard user's have an id starting with 001, the community user's have a ID starting with 005.  And when I do try to assign the ownerID field to one of the 005 user ID's - I get the OP_WITH_INVALID_USER_TYPE_EXCEPTION error.

thoughts?
Has anybody been able to use an AppExchange component (like Hierarchy or iFollow) in a Community (like a Napili template)?

I've installed both of those comonents in my ORG, but I can never find them in the community builder. 
I have a customer community, using the Napili template.  When I use Search - it won't find Saleforce records - like Account, Contact.  How do you get the search to be like a "Search All"?

I have a lightning web component that uses @wire to call to APEX. It works just fine when I place the component on a lightning page and display from a Salesforce user. However, the APEX never get's called when I place the component on a Community page.
Is there a setting that needs to be done to allow access from a community?
Thanks,
please explain the meaning of  below condition.

if(!nummap.containsKey(num))

nummap is Map collection,
num is integer variable ( some integer values like 1,1,2,3,2,3)
I'm working on some more LWC learning - trying to understand how a custom wrapper class is displayed in the component.

If I have this APEX, .js, and HTML - the value of field1 is never displayed - can anyone see my issue?

Thanks!

APEX:
@AuraEnabled(cacheable=true)
	public static wrapperClass  rtnWrapperClass(){
		wrapperClass wrapper = new wrapperClass();
		wrapper.field1 = 'Value for field1';
		wrapper.field2 = 'Value for field2';
		return wrapper;
	}

	public class wrapperClass {
		@AuraEnabled 	public string  	field1		{get;set;}
		@AuraEnabled 	public string 	field2		{get;set;}
		public wrapperClass() {
			this.field1 = field1;
			this.field2 = field2;
		}
	}
.js
import rtnWrapperClass from '@salesforce/apex/HelperAccount.rtnWrapperClass';

export default class showWrapper extends LightningElement {

    // Return  Wrapper Class
    @wire(rtnWrapperClass)
        wrapperClass;

}

and the HTML:
<!-- Data from Wrapper Class -->
            <p>Wrapper Class Data...</p>
            <template if:true={wrapperClass.data}>
                <lightning-formatted-text
                    value={wrapperClass.field1}>
                </lightning-formatted-text>
            </template>



 
So, I have a lightning web component that calls an APEX method to return something.  When I try to display what the APEX returns, I always get [object Object] in the html.

Here's the code:
//.js....
import { LightningElement, api, wire } from 'lwc';
import acceptRtnSomthing from '@salesforce/apex/HelperAccount.acceptRtnSomthing';

export default class UltimateParentMRR extends LightningElement {
    @api recordId;
    somethingReturned = "Value in .js....";
    
    @wire(acceptRtnSomthing, {recId : '$recordId' })
        somethingReturned;

}




// HTML....
<template>
    <lightning-card title="Ultimate Parent MRR" icon-name="standard:account">
        <div class="slds-m-around_medium">
            {somethingReturned}
        </div>
    </lightning-card>
</template>


// APEX...
@AuraEnabled (cacheable=true)
	public static string acceptRtnSomthing(string recId){
		return recId;
	}
If I comment out the call to the APEX - I get "Value in .js...." in the HTML output.

Does anybody see my issue?

Thanks!
 
I'm trying to call the Amazon S3 API from Apex, but keep getting a

System.HttpResponse[Status=Forbidden, StatusCode=403] error. 

I know my end-points, key and secret are correct - as I pasted them directly from a working Postman example.

Can anyone see issues with my code?

Thanks!
 
public  list<string> rtnBucketItems(string bucketName, string key, string secret) {
		if(bucketName==null) 	bucketName 	= '******************************';
		if(key==null) 			key 		= '******************************';
		if(secret==null)		secret		= '******************************';

		String currentTimestamp = datetime.now().formatGmt('EEE, dd MMM yyyy HH:mm:ss Z');

		list<string> bucketItems = new list<string>();

		Http http = new Http();
		HttpRequest request = new HttpRequest();
		request.setMethod('GET');
		request.setHeader('Host','******************************.s3.amazonaws.com');
		request.setHeader('Content-Encoding', 'base64');
		request.setHeader('Date',currentTimestamp);
		request.setEndpoint('https://******************************.s3.amazonaws.com');

		// Build and set Authorization Header
		string stringToSign = 'GET\n\n\n' + currentTimestamp + '\n\n/' + bucketName;
		string stringSigned = rtnSignedString(stringToSign, secret);
		string authHeader = 'AWS' + ' ' + key + ':' + stringSigned;
		request.setHeader('Authorization', authHeader);

		HttpResponse response = http.send(request);
		system.debug('response='+response);

		return bucketItems;
	}


	public string rtnSignedString(string inString, string secret) {
		string signedString;
		Blob mac = Crypto.generateMac('HMACSHA1',blob.valueOf(inString),blob.valueOf(secret));
		signedString = EncodingUtil.base64Encode(mac);
		return signedString;
	}



 
I have a string that is end of line dilimited with the paragraph (or pilcrow), (ascii 0182).

Does anybody know the character to split on? 

ie for a New+Line dilimited it's ...
list<string> lines = fullText.split('\n');

But for the paragraph - I can't seem to find the right character.
Challenge Not yet complete... here's what's wrong: 
The getBoats() method isn't working properly. Define getBoats() In the BoatSearchResults Apex controller to accept an optional boatTypeId and return all boats if no boatTypeId is passed, and a filtered list of boats if a boatTypeId is passed.

getting this error
Hi All

Kindly help me here, i have an apex class for webservice, i require the test class to be completed.

The APEX CLASS is as follows;

global class Sendxxx {
    private static String workOrderId ;
    private static String workOrderStatus ;
    webService static void postToSAP(String orderStatus, String woId) { 
   system.debug('orderStatus'+orderStatus);
      If(orderStatus =='Complete' || orderStatus =='Partially Completed')
       { 
       system.debug('orderStatus'+orderStatus);
        workOrderId  = woId;
          workOrderStatus = orderStatus.tolowercase();
          //workOrderStatus = orderStatus;
        getAndParse();
        
    }
    else
    {
      system.debug('orderStatus'+orderStatus);
     }
      }
    
  global static void getAndParse() {
    
        HttpRequest req = new HttpRequest();
  
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        //String strname = 'Username';
       // String strpwd= 'pwd';
        //String SessionId = Userinfo.getSessionId();
        String strURL = System.URL.getSalesforceBaseURL().toExternalForm();
        req.setEndpoint('https://elastic.snaplogic.com:443/api/1/rest/slsched/feed/xxxx/xx/xxxrviceMax/SVMXC_SumEstimatedTime_Task?work_order_id='+workOrderId+'&state='+workOrderStatus);
        req.setHeader('authorization','Bearer owhBgvxxxxxxz');
        req.setTimeout(120000);
        req.setHeader('cache-control', 'no-cache');
        req.setMethod('GET');
        
        JSONGenerator gen = JSON.createGenerator(true);
            gen.writeStartArray();
            gen.writeStartObject();
            gen.writeStringField('SVMXC__Service_Order__c', workOrderId );
           gen.writeStringField('SVMXC__Order_Status__c',workOrderStatus );
            gen.writeEndObject();              
          gen.writeEndArray();
          String jsonOrders = gen.getAsString();
           System.debug('jsonOrders: ' + jsonOrders);
          req.setHeader('Content-Type', 'application/json');
          req.setHeader('Accept-Encoding', 'gzip');
           req.setBody(jsonOrders);
            req.setCompressed(true); // otherwise we hit a limit of 32000 
        try {
            res = http.send(req);
            
            if (res.getStatusCode() == 200 ) {
            
             System.debug('CALLOUOT SUCCESSFUL');
             System.debug('RESPONSE FROM CPQ 1111--->'+res.toString());
             System.debug('RESPONSE BODY--->'+res.getBody());
            }
        }             
        catch(System.CalloutException e) {
            System.debug('Callout error: '+ e);
            System.debug('RESPONSE FROM CPQ'+res.toString());
        }
        
 }
 }
Hey,

Im trying to display maps in a visualforce page but the method that builds the map doesnt seem to be called when i preview my page. I would appreciate some help please :)

Here's my map : 

public map<string,string> getMapFieldLabel(){
        
        //List<string> fieldsLabels = new List<string>();
        List<Custom_Object__c> defaultFields = [Select Name from Custom_Object__c where Default__c=True];
        Map<String, Schema.SObjectField> typeMap = Schema.SObjectType.A_second_Custom_Object__c.fields.getMap();
          
        //Get choosen default fields label    
        for(Custom_Object__c defaultField : defaultFields) {
            
            Schema.SObjectField field = typeMap.get(defaultField.Name);
            string fieldLabel =field.getDescribe().getLabel();
            mapFieldLabel.put(defaultField.Name, fieldLabel);
            //fieldsLabels.add(fieldLabel);
            
            
        }
        system.debug(mapFieldLabel);
        return mapFieldLabel;
        
    }

And my VF code : 

         <apex:pageBlockSection columns="3" collapsible="true">
                
            <apex:repeat value="{!MapFieldLabel}" var="item" >
                    
                    <apex:repeat value="{!MapFieldLabel[item]}" var="itemvalue" >                    
                    <apex:outputText value="{!itemvalue}" />
                    </apex:repeat>
            </apex:repeat>   
            </apex:pageBlockSection>

This code doesnt display anything on screen !

Thank you for your help in advance :)
I am not sure when/whether I should put logic inside Apex class or use Visualforce page to display data.

Here is logic.
Depending on the 
SurveySelection, it would display data (surveytype) differently.

Logic:

If  (SurveySelection__c = 1) {
              Surveytype__c = “final1” and “final2”
} else if (SurveySelection__c = 2) {
              Surveytype__c = “midterm1” and “midterm2”
} else {
              Surveytype__c = “openbooktest1” and “openbooktest2”
}
  

My question is: should I use If Statement inside APEX code like below or should I program inside VF page?​

Here is some Apex code that I have:

 
Public  PageReference   searchStudents()
{
students = [ select
                           LName__c
                           , (select SurveySelection__c from SurveySelections__r )
                           From Student__c ];
 
surveyselections = [select
                             SurveySelection__c
                             From SurveySelection__c ];
 
surveyreference  = [select
                             SurveyType__c
                             From SurveyReference__c ]; 
              Return null;      
}
 
 
I know in the order of operations, triggers fire before workflows, then if there are field updates, the record is updated and triggers fire again.

Most SF developers and admins are of the opinion that you should do as much declaratively via Workflows, Process Builder, etc. and not use triggers and Apex code unless the use case is such that it cannot be implemented via declarative features.

But when you do need triggers, if you have field updates, you have to be very careful that they don't interfere with each other and have to consider any bad effectst that could happen from a trigger fireing more than once.

So I'm wondering if perhaps it's best to implement with a pattern that once triggers are needed, then avoid doing field updates via declarative features and do all field assignments in the triggers.  The downside is admins can no longer define simpler features.  But the upside is that all the record assignments are then in one carefully controlled stream of code executed by the trigger.

Thoughts?
 
Hi All,
 
I am facing an issue in which i am getting lists of lists from Controller in lightning and want to set into array because i need each index of element from that list of lists.Here is the code.
Public static list<List<ZenObject__c>> getZenObjsOdd(){
          Integer colcount=getColumnsCount();
          Integer index=0,i;
          
      list<list<ZenObject__c>> lst=new list<list<ZenObject__c>>();
          List<ZenObject__c> ZenobjsOdd=new List<ZenObject__c>();
      List<ZenObject__c> Zenobjs=[Select ZenLms_Name_del__c,ZenLms_SubText__c,ZenImage__c from ZenObject__c order by createddate];
          integer listsize=Zenobjs.size();        
          for(integer col=1;col<=(listsize/colcount);col++){ 
              for(i=index;i<(index+colcount);i++){
                  ZenobjsOdd.add(Zenobjs[i]);    
              }  
              index=i;
               lst.add(ZenobjsOdd); 
          }
          if(math.mod(listsize,colcount)!=0)
          {
              for(integer j=index;j<index+(math.mod(listsize,colcount));j++){
                  ZenobjsOdd.add(Zenobjs[j]);
                  lst.add(ZenobjsOdd); 
                 
              }
          }
        return lst;  
      }

//JS controller
 getZenObjsOdd : function (component){
      var action = component.get("c.getZenObjsOdd"); 
 var items[];
      action.setCallback(this, function(actionResult){
        var state = actionResult.getState();
          if (component.isValid() && state === "SUCCESS"){ 
              items.push(JSON.stringify(actionResult.getReturnValue()));
              console.log('hihih ' +items);
             component.set("v.ZenObjsOdd",items);             
              } 
      });
         $A.enqueueAction(action);
},

From the code it is clear that i am pushing actionResult.getReturnValue()  in array.But there is something wrong here.Anyhelp would be appreciated,


Thanks,
Deepak.

I have a user requirement that our current Salesforce object, developed in Visualforce be cleaned up. The 
user requirement is that evidentuary information be captured for a case. Currently, through visualforce, we 
have developed a screen that looks like the followig: (except when it is running, the files address is on the same line as the rest of the information.)

Witness name    Witness phone     Witness address        Witness city    Witness e-mail        Deposed    Deposition file 
Jane Doe    916-555-1212    123 Main Street        Sacramento    janedoe@anymail.com    Yes     C:/My Documents/Cases/JanedoeDeposition05042017.WMV
John Doe    916-555-1212    123 Main Street        Sacramento    johndoe@anymail.com    Yes     C:/My Documents/Cases/JohndoeDeposition05042017.WMV
Sue Smith    916-555-1111    133 Main Street        Sacramento    suesmith@anymail.com    Yes     C:/My Documents/Cases/SuesmithDeposition05042017.WMV
Tom Thumb    916-555-2222    113 Main Street        Sacramento    tomthumb@anymail.com    Yes     C:/My Documents/Cases/tomthumbDeposition05042017.WMV


The section of the code that I am currently using to accomplish the above is similar to this: 
 
<apex:pageBlockTable value="{!WitnessEntries}" var="entry" id="Entry_Table_List">
                <apex:column width="70" headerValue="Witness name">
                    <apex:inputField value="{!entry.Witness_name__c}"/>
                </apex:column>    
                <apex:column width="60" headerValue="Witness phone">
                    <apex:inputField value="{!entry.Witness_phone__c}"/>
                </apex:column>    
                <apex:column width="20" headerValue="Witness address">
                    <apex:inputField value="{!entry.Witness_address__c}"/>
                </apex:column>    
                <apex:column width="20" headerValue="Witness city">
                    <apex:inputField value="{!entry.Witness_city__c}"/>
                </apex:column>  
                <apex:column width="80" headerValue="Witness e-mail">
                    <apex:inputField value="{!entry.Witness_e-mail__c}"/><br/>
                </apex:column>  
                <apex:column width="80" headerValue="Deposed">
                    <apex:inputField value="{!entry.Deposed__c}"/><br/>
                </apex:column>  
                <apex:column width="80" headerValue="Deposition file">
                    <apex:inputField value="{!entry.Deposition_file__c}"/><br/>
                </apex:column>  
            </apex:pageBlockTable>

However, what the user wants to see is a form that looks like the following so that it is easier for them to 
digest the information at a glance. 

Witness Name:    Jane Doe       Witness Phone: 916-555-1212    Witness e-mail:  janedoe@anymail.com
Witness address: 123 Main Street   Witness City:  Sacramento     Witness deposed: Yes 
Witness Deposition File: C:/My Documents/Cases/JanedoeDeposition05042017.WMV

Witness Name:    John Doe       Witness Phone: 916-555-1212    Witness e-mail:  johndoe@anymail.com    
Witness address: 123 Main Street   Witness City:  Sacramento     Witness deposed: Yes 
Witness Deposition File: C:/My Documents/Cases/JohndoeDeposition05042017.WMV

Witness Name:    Sue Smith       Witness Phone: 916-555-1111    Witness e-mail:  suesmith@anymail.com    
Witness address: 133 Main Street   Witness City:  Sacramento     Witness deposed: Yes 
Witness Deposition File: C:/My Documents/Cases/SuesmithDeposition05042017.WMV

Witness Name:    Tom Thumb       Witness Phone: 916-555-2222    Witness e-mail:  tomthumb@anymail.com    
Witness address: 113 Main Street   Witness City:  Sacramento     Witness deposed: Yes 
Witness Deposition File: C:/My Documents/Cases/tomthumbDeposition05042017.WMV

Thank you in advance for how I might accomplish this. 

Respectfully, 

Eric Anderson
I have a Schedulableclass which is scheduled to execute every night at 12:00 AM,  here is my class, 


*****
public class appdevDailySnapShot implements Schedulable{
    public List<App_Dev__c> ac {set;get;}    
    public void execute(SchedulableContext con){
        List<App_Dev_Log__c> lstADL = new List<App_Dev_Log__c>();
        try
        {               
           ac=[select Name,Assigned_To__c,Category__c,Completed_date__c,Effort_Hrs__c,Environment__c,Expected_QA_Date__c,In_Progress_Date__c,Old_Create_Date__c,Old_Request__c,On_Hold_date__c,Priority__c,Production_Release_Date__c,Project__c,Ready_for_Production_Release__c,Released_in_QA_Date__c,Released_in_UAT_date__c,Requested_QA_Release_Date__c,Status__c,SVN_update__c,Type__c,Unit_testing_DEV__c,Verified_in_Production__c,Verified_in_QA_Date__c,Verified_in_UAT_date__c from App_Dev__c];            
            for(App_Dev__c adc : ac)
            {
                App_Dev_Log__c AL = new App_Dev_Log__c();
                AL.AD_Request_No__c = adc.Name;
                AL.Assigned_To__c = adc.Assigned_To__c;
                AL.Category__c = adc.Category__c;
                AL.Completed_date__c = adc.Completed_date__c;
                AL.Effort_Hrs__c = adc.Effort_Hrs__c;
                AL.Environment__c = adc.Environment__c;
                AL.Expected_QA_Date__c = adc.Expected_QA_Date__c;
                AL.In_Progress_Date__c = adc.In_Progress_Date__c;
                AL.Old_Create_Date__c = adc.Old_Create_Date__c;
                AL.Old_Request__c = adc.Old_Request__c;
                AL.On_Hold_date__c = adc.On_Hold_date__c;
                AL.Priority__c = adc.Priority__c;
                AL.Production_Release_Date__c = adc.Production_Release_Date__c;
                AL.Project__c = adc.Project__c;
                AL.Ready_for_Production_Release__c = adc.Ready_for_Production_Release__c;
                AL.Released_in_QA_Date__c = adc.Released_in_QA_Date__c;
                AL.Released_in_UAT_date__c = adc.Released_in_UAT_date__c;
                AL.Requested_QA_Release_Date__c = adc.Requested_QA_Release_Date__c;
                AL.Status__c = adc.Status__c;
                AL.SVN_update__c = adc.SVN_update__c;
                AL.Type__c = adc.Type__c;
                AL.Unit_testing_DEV__c = adc.Unit_testing_DEV__c;
                AL.Verified_in_Production__c = adc.Verified_in_Production__c;
                AL.Verified_in_QA_Date__c = adc.Verified_in_QA_Date__c;
                AL.Verified_in_UAT_date__c = adc.Verified_in_UAT_date__c;
                AL.Snapshot_Date__c = date.today();
                AL.Snapshot_Time__c = datetime.now();
                lstADL.add(AL);
            }        
            insert(lstADL);
        }
        catch(Exception pEx){
            System.debug('**** Exception Inserting in APP_DEV_Log ****');
            System.debug(pEx.getMessage());
        }
        finally{
            lstADL.clear();
            lstADL = null;
        }
    }   
}

************

here is my test class,  my code coverage is 22%.

@istest
public class appdevDailySnapShot_Test {
    static testMethod void testSample1(){
        Test.startTest();
        Datetime dt2 = Datetime.now().addMinutes(1);
        String CRON_EXP2 = '0 '+ dt2.minute() + ' * ' + dt2.day() + ' ' + dt2.month() + ' ? ' + dt2.year();
        Id jobId = System.schedule('AppDev Daily Snapshot - Test1', CRON_EXP2, new appdevDailySnapShot());
        Test.stopTest();
        System.assert(jobId != null);
    }
    static testMethod void testSample2() {
        Test.startTest();
        Datetime dt = Datetime.now().addMinutes(1);
        appdevDailySnapShot aObj = new appdevDailySnapShot();
        String CRON_EXP = '0 '+ dt.minute() + ' * ' + dt.day() + ' ' + dt.month() + ' ? ' + dt.year();
        String jobId = System.schedule('AppDev Daily Snapshot - Test2', CRON_EXP, aObj);   
        Test.stopTest();
    }



How to increase the code coverage .. Could you guys please help.
 
I have tried using this format: 

<apex:image id="Logo" value "url image link" /> 

But its not displaying the logo, just the link. 

Thanks,

Eric 
I am trying to write a, IF statement in a formula that will evaluate as follows:
If field A is greater than or equal to 27 OR either field B OR field C are greater than or equal to 610, AND field D is equal to MG-UG, return the value of Option1” otherwise go to the next criteria and so on.

 
Below is what I used.  It did not return a syntax error but it also did not work.  I suspect the issue to be in the “either” part of the formula.
 
IF(Highest_ACT_Composite__c  >= 27 || ((Highest_SAT_I_Verbal__c >=610 ||(Highest_ERWS__c >=610)) && (Contains("MG-UG",(Student_Rec_Major_Code_1__c)))),"Business Math",
 
Any insights would be greatly appreciated.
 
Hello,

I would like some help to bulkify the code bellow:
 
for (Trip__c trip : trigger.new )
{
	List<Trip__c> myTrips = [Select ID from Trip__c WHERE day__c =:trip.Day__c 
                            and driver__c =:trip.driver__c];

    .... rest of the code ....
}
Thanks
 
We currently use complex Conga merge documents, and then attach them to an Echosign agreeemt.  Well, now I'd like to find a way to drop the Conga documents from the process.  Document is getting even more complex, and I'm going to use visualforce and apex to create the document that is to be signed. So, ...

Can visualforce rendered as a PDF, have embedded signature tags?  

Thanks

 
Hi,
I am using Eclipse for Light component development. Initially I developed in dev console and recently started working in Eclipse.For Some of the components that i developed using dev console.I have not created helper and Renderer and CSS file. When I fetched them into my eclipse, only component and controller code has been fetched which is understandable as I only have that code created. Now when I am looking for an option to create a helper/style for that component but could not find an option to do it directly in eclipse. I could only see new lightning component bundle creation option.
One work around might be to go back to dev console, create helper/style and then fetch it to eclipse. I want to know if there is an option to directly create that in eclipse.

Nihar.
Hi,

There is no clear and simple explanation of what a connected app can be used for - if I want to query Salesforce through the REST API (for any reasons, from any external point), why would I need a "Connected App"? What's the difference with creating a Salesforce "Integration" User with an "Integration" Profile that restricts exactly what you want/need for that specific integration?

Thanks for anyone's help.

Regards
Anthony
I have a VF page which contains a output link and passing some values as query string to another VF page.  
I am using the same vf pages in lightning experience but the problem i am facing is i am not getting Query string values, when i  switcehd to lightning experice. how can I get VF page query strings if i am in lightning experience.  
  • March 28, 2017
  • Like
  • 1
Are there any samples or docs for this. I've attempted to create an Apex Trigger on FeedComment, but it's just doesn't seem to work. I would also have to get the user ID of the original post etc.

Essentially all I want to do is send push to a user who's post was commented on. Seems like a pretty standard thing to do. Is there no easy way to do this with the Chatter API?
Hello, 

I was asked to take a stab at implementing another system with Salesforce which will pull information from Salesforce Opportunity object into their mobile app. Since this is my very first time working with API's, I'm extremely lost on where to start. 

I read bunch of articles and the developer guide to understand the different API's and their use. However, my confusing is on what the first step is, I should be taking.

Problems or task at hand: We are looking at a mobile Timecard application, where users will use the app to login and pull up a Opportunity record (I'm guessing this is just the name of opportunity) and stamp their time to clock in and out of a job. I was provided with their TimeCard SOAP API documentation to take a look at the api's and the library. 

Questions
1. What is the first step should I be doing? (If I'm not wrong, I believe we will also be updating few fields on Opportunity after they have entered their time to clock in or out. If not Oppostunity record, then related object to Opportunity) 
2. What questions should I be asking them (the developer from Timecard app)? 
3. Do I write a webservice, generate Apex WSDL and give it to them? (Assuming data needs to go from Salesforce to their system)
4. I don't have any experience in .NET, do I need to? 
5. Why do I need to look at their API documentation? Are they assuming that I will be writing code on their end? Again, going back what should I be asking them? How does this usually work?
6. What do I do with the WSDL file when they give me their, if they do (steps by steps)? 

As you can tell I have never worked with webservices and api's but I think this is a very good opportunity for me to learn hands on and work with it. Even though it is very short amount of time to soak everything up, I am hoping someone will guide me to the right direction. Also, I do not have any mentor or go to person to ask since I'm the solo Salesforce person working here. SO, I will be needing lots of help. Any guidance will be truly appreciated! 

Thank you. 
Hello,

Before I spend a ton of time researching the plausibility of what we want to do I wanted to ask the forum. 

We have many attachments on the Opportunity object, and part of our process when we close opportunities is to print all the attachments associated. 
Due to the clunkiness of printing each attachment it takes quite a bit of time to do this. Is it possible to print all the attachments from a visualforce page thats called by a button click? 

I've read similar requests but I haven't seen if it's actually plausible.

thanks in advance! 
I have an VisualForce page set up like this:
<apex:actionPoller interval="5" reRender="panel" action="{!getPanelRecords}"/>

<apex:outputPanel id="panel">
    <button onClick = "btnClick(this,'blue');" value="Change me blue"/>
    <button onClick = "btnClick(this,'red');" value="Change me red"/>
</apex:outputPanel>

<script>
    function btnClick(element, color) {
        this.attr('color', color);
    }
</script>

When I click the button, it will change color, But due to the panel getting rerendered, it will not persist between refreshes.

I was thinking of using the actionPoller onComplete event to get a list of id's and set the colors accordingly, but I'm not sure if there's an easier/better way to achieve this.

Can anybody recommend how to store the changed CSS on multiple elements between refreshes?
Hi, to all I am new in the extension controller here I try implement the function on the sorting to my visual force page but the sorting and pagination is not working together here(I already done the pagination only using the standard controller). So I check the developer console on my apex class it's provide the error on followingly in the image
User-added image
So I don't know how to clear this error so please help me to done this task.and my apex class is followingly,
public class AccountListViewController{
public List<Account> AccountsortList {get; set;}
public String SortingExpression = 'name';
public String DirectionOfSort = 'ASC';
public Integer NoOfRecords {get; set;}
public Integer Size{get; set;}

    public AccountListViewController(ApexPages.StandardSetController controller) {
        AccountsortList = new List<Account>();
        ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(AccountsortList);
        
    }
    
    /*public Integer pageNumber {
        get {
        return ssc.getpageNumber();
        }
        set;
    }*/
    public String ExpressionSort {
        get {
            return SortingExpression;
        }
        set {
            If(value == SortingExpression) {
                DirectionOfSort = (DirectionOfSort == 'ASC')? 'DESC' : 'ASC';
            }
            else {
                DirectionOfSort = 'ASC';
                SortingExpression = value;
            }
        }
    
    }
    
    public String getDirectionOfSort() {
        If(SortingExpression == Null || SortingExpression == '') {
            return 'DESC';
        }
        else {
            return DirectionOfSort;
        }
    }
    
    public void setDirectionOfSort(String value) {
        DirectionOfSort = value;
    }
    
    public List<Account>getAccounts() {
        return AccountsortList;
    }
    
     public PageReference ViewData() {
        String FullSortExpression = SortingExpression + ' ' + DirectionOfSort;
        system.debug('SortingExpression:::::'+SortingExpression);
        system.debug(DirectionOfSort);
        
       String Queryitem = ' SELECT Id, Name, Phone, BillingState, Type, Owner.Name, Website FROM Account WHERE Account.Name != Null ORDER BY ' + FullSortExpression +' Limit 10';
       system.debug(Queryitem);
       
        AccountsortList = DataBase.query(Queryitem);
        system.debug(AccountsortList);
        return Null;
    }
}

For answer's thanks in advance.Thanks Mohan. 
Having some trouble using the Force.com IDE in Eclipse Java Neon and wondering if anyone has seen something similar/can help.  Here is where I'm at:

I've installed Java JDK 1.8.0_101
I've installed Eclipse Neon IDE for Java Developers, as recommended here: https://developer.salesforce.com/page/Force.com_IDE_Installation
Upon opening Eclipse, I've followed the instructions to "Install New Software" and Added the Force.com IDE, and finished installation (it shows in the list in "Installation Details")

However, when I go to Window > Perspective > Open Perspective > Other, it does not show in the list.  I've repeated the above steps a few times and restarted, and still no luck.  Anyone have any ideas?
How would one access the einstein scores or einstein tips for the salescloud. Is there a new Salesforce object that I'm not seeing? Or is it a field of an existing object?

I've search thru the documentation and can't find anything for developers about einstein.
Hello everyone, under Campaign, there is an attachments section. I have created a custom field called summary. The attachments are likely going to be Microsoft Word documents at all times. Is there a way where I can attach a word file and have the text from the file automatically populate the summary field? Right now we are copying and pasting the text, this is just an extra step for us.

Thanks in advance!

https://success.salesforce.com/answers?id=9063A0000019QCFQA2
whats is live agent in sfdc and what are the steps to sucessfully implement it ? Thanks
Diedrich Roasters in beautiful Sandpoint, ID, is looking for a Salesforce Developer to contract for developing a Project Management (maybe start with TaskRay and build from there) to make our process more streamlined and efficient.

More information about our company can be found at www.deiderichroasters.com. If you or anyone you know is interested, please contact us at info@diedrichroasters.com.
 

Hi,

When a trigger fires it process the records modified by one user or more users? For example if 2 users edit one record each(from the same object) and click save in the same time then these 2 records will be processed in the same trigger execution or it will be 2 executions of the trigger?

If write userId = UserInfo.getUserId() in a trigger, what user id it will return?

Thanks!

Hi All,
We are re-building a webstie that used Dynamics CRM as the backend system.  The new website will use Salesforce.  We'll be using Salesforce to store users' login information.  Due to the SF API limit, we want to avoid having to make a call to SF to authenticate users as much as possible.  We are new to Salesforce and would like to hear your opinions/suggestions on how to best accomplish this?  Our website has heavy traffic that will continue to grow so we feel like continuing to increase our API limit is not a good long term solution.
Hi there,

I have recently integrated Adobe Sign with Salesforce through AppExchange but was having some problems with retrieving the Signing URL for any document that has been uploaded.

The link that I can access by querying the Signing URL field, is the link that is sent to the sender of a document and not the link needed for a recipient to preview and sign a document. Could you please advise as to how to retrieve this URL through Salesforce, for a recipient to be able to click on the link and be taken to preview and sign any such document?

Thank you!
I'm getting " TLS 1.0 has been disabled in this organization. Please use TLS 1.1 or higher when connecting to Salesforce using https." error when I refresh my eclipse. I performed below actions to fix the issue, but I'm not able to fix the error. 

1) Checked the critical updates - There is no update related to TLS 1.0 in my sandbox
2) I have Java 1.7 Version and enabled TLS 1.1 and 1.2. 
3) Enabled TLS 1.1 , 1.2 in all the browsers.
4) Added "-Dhttps.protocols=TLSv1.1,TLSv1.2"

Please let me know, is anything am missing here to fix this issue? 

User-added image
We have been using OAuth 1.0 to authorize our app on Google App Engine for the last 4 years,
From last week this process stopped wotking (with summer 16 release).

I wonder if anyone has encounter this issue?

More technically, when we start the process, we can see that we get a request token and token secret, although when we invoke the authorization URL we get a GACK screen from SalesForce.com

Any help will be highly appreciated (we also work with SalesForce support on this issue...)
  • June 22, 2016
  • Like
  • 2
I'm using the following code inside my custom chat agent window.

<liveAgent:clientChatQueuePosition label="People waiting" rendered="true" />

For some reason I get to see the label, but I don't see the queue position.

Any ideas?

Thanks!
I am using a Visualforce email Template. I am unable to fetch merge fields. Below is the code:

<messaging:emailTemplate subject="Volunteer still needed for a shift" recipientType="User" relatedToType="GW_Volunteers__Volunteer_Shift__c">
<messaging:plainTextEmailBody >

Volunteer is still needed for a future shift. Please click below to see the shift.
https://cs18.salesforce.com/{!relatedToType.Id}

</messaging:plainTextEmailBody>
</messaging:emailTemplate>

When I try to save it, it gives error like
Error:Unknown property 'String.Id'