• bharath kumar 52
  • NEWBIE
  • 95 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 4
    Likes Received
  • 66
    Likes Given
  • 65
    Questions
  • 30
    Replies

I have a requirement where i need a opportunity related task to appear under related opportunity's account and contact but i am able to see it only under related account and not under related contact.Can someone tell what is going wrong here and is it possible to achieve this using a process builder ?

Hi All,

I am planning to integrate salesforce with a google api. But, the challenge here is that i have a lot of users and  each user has a different set of data.
In order to make sure that the user data flows from google to salesforce i used their api and REST callouts . But, the catch here is that i am currently hardcoding the token which i get from oauthplayground. But in realtime scenario when i click on a button i need the latest dataa to be shown from google to salesforce can someonen please help me on how i can get the token of each user dynamically and notjust hardcoding a single token?

Hi All,

I am trying to save the currently applied "class" which is triggered onclicking s,m or l of the particular record of an sobject which should be saved in a field of user object and i need to do it for more than one record. How can i achieve this requirement? Can someone help me with the approach if not for the code?
Tiles image

Thanks,
Bharath

Hi All,

I am working on a PoC where i need to display sobject records cards. But when i do i have few hyperlinks on each card onclick of which i want my card to be resized. I used addstyle but am not able to do it for more than 1 record.
Also, is there any way to store the card size for that particular user? i.e when i resize the card it should be visible with the same size next time the user visits the page.
<aura:component controller="tileController">
    <aura:attribute name="tiles" type="TileRecord__c[]" />
    <aura:attribute name="tileCount" type="Integer" default="0" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    <lightning:layout multipleRows="true">
      
        <aura:iteration items="{!v.tiles}" var="tile" indexVar="index">
            <lightning:layoutItem padding="around-small" size="10" smallDeviceSize="12" mediumDeviceSize="6" largeDeviceSize="4" >
               
                <article aura:id="{!tile.Id}" class="slds-card slds-card__narrow slds-size_2-of-3" style="padding-left: 10px;" data-row-index="{!index}">
                    <a href="{! '#tiles/' + tile.Id }">
                        
                        <span class="slds-badge">{!tile.Name}</span>
                    </a>
                    
                    <!--<lightning:button label="Toggle" onclick="{!c.resizeToSmall}"/> -->
                    <p><!--<ui:button aura:id="sml" press="{!c.resizeToSmall}">s</ui:button> -->
                        <a aura:id="md" href="javascript:void(0)" onclick="{!c.resizeToSmall}">s</a>
                        <a aura:id="md" href="javascript:void(0)" onclick="{!c.resizeToMedium}">m</a>
                        <a aura:id ="lg" href="javascript:void(0)" onclick="{!c.resizeToLarge}">l</a>
                    </p>
                    
                    <p>{!tile.Description__c}</p>
                    <p style="color:red; font-weight:bold;">{!index}</p>
                    
                    <a href="javascript:void(0)" onclick="{!c.doSomething}">
                        Click me to do Something </a>
                    
                </article>
                  
            </lightning:layoutItem>
        </aura:iteration>
       
    </lightning:layout>    
    
</aura:component>

Controller :
({
	doInit : function(component, event, helper) {
		var tiles=component.get("c.displayTiles");
        tiles.setCallback(this,function(a){
            component.set("v.tiles",a.getReturnValue());    
        });
        $A.enqueueAction(tiles);//tiles ---> action on server side	
	},
    applyCSS: function(cmp, event) {
        //var href = event.currentTarget;
        //$A.util.addClass(href, 'changeMe');
         var cmpTarget = cmp.find('{!tile.Id}');
        $A.util.addClass(cmpTarget, 'changeMe');
    },
    resizeToSmall:function(component, event, helper){
//OnClick on s,m,l hyperlinks on the component it should be resized.
       	/*var src = event.getSource().getLocalId();
        
        var cmpTarget = component.find('changeIt');
        $A.util.addClass(src, 'changeMe');
        console.log('After');*/
        var cmpTarget = component.find('{!tile.Id}');
        console.log('target'+cmpTarget);
        var arr = [];
        //arr = component.find("main").getElement().childNodes;
        //console.log(event.target);
        
        
    },
    resizeToLarge:function(component, event, helper){
        
        console.log('Large');
    },
    resizeToMedium:function(component, event, helper){
        
        console.log('Medium');
    },
    doSomething : function(component,event, helper) {
       console.log('Hey There .. the anchor was clicked');
       console.log(event);
       var href = event.srcElement.href;
       console.log(href);

    } 
})

 
Hi All,

I am working on a PoC where i am consuming data from an external servcie and displaying it on a VF page.
Can someone let me know where i am going wrong and what needs to be done to display the data on the VF page.
public class TickerData {
	
	public list<Prices> pricelist{get;set;}
    private static String endpoint='https://koinex.in/api/ticker';
    
    public list<Prices> getmakeTickerData(){
		
		
		pricelist = new list<Prices>();
        Http http= new Http();
        HttpRequest request= new HttpRequest();
        request.setendpoint(endpoint);
        request.setMethod('GET');
        HttpResponse response = http.send(request); //response contains json body
        
        if(response.getStatusCode()==200){
            system.debug('Response'+response.getBody());
            //JSON2Apex js=JSON2Apex.parse(response.getBody());
            JSONParser parser = JSON.createParser (response.getBody()); 
   			while (parser.nextToken()!=null) { 
                if (parser.getCurrentToken()== JSONToken.START_ARRAY) {    
                    while (parser.nextToken()!= null) { 
                        
                        //
			if(response.getstatusCode() == 200 && response.getbody() != null){

				pricelist=(List<Prices>)json.deserialize(response.getbody(),List<Prices>.class);

			}//
                        /*if (parser.getCurrentToken()== JSONToken.START_OBJECT) { 
                            JSON2Apex the = (JSON2Apex) parser.readValueAs (JSON2Apex.class); 
                        }*/
                  }
            }
			
			
            //Map<String,Object> results=(Map<String,Object>)JSON.deserializeUntyped(response.getBody());
            /*List<Object> prices=(List<Object>)results.get('prices');
            
            for(Object o:prices){
                System.debug('Prices :'+o);
                
            }*/
        	}
        
    	}
        return pricelist;
	}


	public class Prices {
		public String BTC{get;set;}
		public String ETH{get;set;}
		public String XRP{get;set;}
		public String BCH{get;set;}
		public String LTC{get;set;}
		public String NEO{get;set;}
		public Double MIOTA{get;set;}
		public String TRX{get;set;}
		public String OMG{get;set;}
		public String AE{get;set;}
		public String ZRX{get;set;}
		public String GAS{get;set;}
		public String BAT{get;set;}
		public String GNT{get;set;}
		public String REQ{get;set;}
		public String AION{get;set;}
		public String NCASH{get;set;}
		public String XLM{get;set;}
	}
	
    public class JSON2Apex {
		public Prices prices;
		public Stats stats;
	}
    
	public Prices prices;
	public Stats stats;

	public class ETH {
		public String currency_full_form;
		public String currency_short_form;
		public String per_change;
		public Double last_traded_price;
		public String lowest_ask;
		public String highest_bid;
		public String min_24hrs;
		public String max_24hrs;
		public Integer vol_24hrs;
	}

	public class Stats {
		public ETH ETH;
		public ETH BTC;
		public ETH LTC;
		public ETH XRP;
		public ETH BCH;
		public ETH OMG;
		public ETH REQ;
		public ETH ZRX;
		public ETH GNT;
		public ETH BAT;
		public ETH AE;
		public ETH TRX;
		public ETH XLM;
		public ETH NEO;
		public ETH GAS;
		public ETH NCASH;
		public ETH AION;
	}

}
 
VF Page :

<apex:page controller="TickerData">
<apex:form>

<apex:pageBlock >

<apex:pageBlockTable value="{!makeTickerData}" var="wrap" width="100%">
<apex:column headerValue="BTC" value="{!wrap.BTC}"/>
<apex:column headerValue="ETH" value="{!wrap.ETH}"/>
</apex:pageBlockTable>

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

 
Hi All,

I have been doing some PoCs around lightning and there's one  concept that i feel is hard to understand "events" .I am not able to relate to a scenario where i use them.I understand events in javascript like "onhover","onclick","onchange".
But in lightning i sense that things are way more complicated.Can someone please explain me with an example or give me a scenario or a realtime use case where you've used it?

Thanks,
Bharath Kumar
Hi All,

I am working on a project and in the data model i can see "Created By and Last modified By" for some objects and "Created By, Last modified By and Owner name" for some objects(all are standard fields). May i ask you that on what basis are the owner fields added?(In general context)

Thanks and Regards,
Bharath Kumar M
Hi All,
Is there any way to get the id of retrieve job in workbench?

Hi All,

Can someone tell me the difference between the 2 methods in the below and when should you go for parameters and non parameters(tjough they are used to achieve the same functionality)
 

public class WithandWithoutParams {
public integer a=2,b=3;
    public void meth1(){
        integer c= a+b;
        system.debug('Value without params >>>>>>'+c);
        
    }
    public void methwithparams(integer x,integer y){
        x=a;//overrides the value of this.a
        y=b;
        system.debug('x'+x+''+'y'+y);
        //y=this.y;
        //system.debug('xxxxx'+x);
      this.a=x;
        this.b=y;
        system.debug('a'+a+''+'b'+b);
        system.debug('x'+x+''+'y'+y);
       // x=this.x;
        integer z= x+y;
        system.debug('Value with params >>>>>>'+z);
        
    }
    
    
}

Hi All,

Following is my data model :

Event (Custom) ---> Child--->Grandchild

My requirement is to send an email alert to a user in a lookup of grandchild WHEN either a "Parent,Child or Grandchild is updated".
Any help on achieving this with a single trigger/workflow is greatly appreciated.(I believe we need to use more than one trigger /workflow for this)
 

Hi All,

I am working on a scenario where i have 2 objects : Accounts and Order1__c(order1 has a lookup relationship with account).
On deletion of account i am able to delete the related child records. But on undelete i am getting the error.

On undelete
Below is my implementation for the same.

trigger OrderDeletion on Account (before delete,after delete,after undelete) {
    
List<Id> AccIds= new List<Id>();
    
    for(Account acc: trigger.old){
       
        
        AccIds.add(acc.id);
    }
    List<Order1__c> ordlist=[select id,name,Account__c from Order1__c WHERE Account__c in:AccIds ];
    if(ordlist.size()>0)
    delete ordlist;
    
    if(trigger.isAfter && trigger.isUndelete){
        if(ordlist.size()>0)
        undelete ordlist;
        
    }
}
 


 

Hi All,

I am new to lightning development and am trying to accomplish the following :
1.)Display a list of pictures stored in attachment object.
2.)Select a pic and save it as dp.

Below is my implementation of the same. But i am not able to display them on the screen.
<!-- Component -->
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" 
                controller="displayAttchmentList" access="global">
    <!--force:LightningQuickAction,force:hasRecordId,-->
    <aura:handler name="init" action="{!c.returnAttList}" value="{!this}" />
    <aura:attribute name="atlist" type="String"/>
   <!-- <aura:attribute name="contactId" type="String" default="0032800001EXXan"/>
    <aura:attribute name="Pic" type="String"/> -->
    <div>
    	<table class="slds-table slds-table--bordered slds-table--cell-buffer">
                <thead>
                    <tr class="slds-text-title--caps" style="background: rgb(159, 170, 181);">
                        <th scope="col">
                            <div class="slds-truncate" title="Id">Id</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Body">Attachment body</div>
                        </th>
                       
                        
                    </tr>
                </thead>
                <tbody>
                    
                   
                
                    <aura:iteration items="{!v.atlist}" var="acc">
                        <tr>
                            <td>
                                <div class="slds-truncate">{!acc.Id}</div>
                            </td>
                            <td>
                                <div class="slds-truncate"><img src="https://resttestdomain-dev-ed.lightning.force.com/one/one.app#/sObject/0032800001EXXanAAH"/></div>
                            </td>
                            
                          <!--  <td>
                                <div class="slds-truncate"><ui:outputRichText value="{!acc.body}"/>
</div>
                            </td> -->
                            
                        </tr>
                        
                        
                            
                    </aura:iteration>
                </tbody>
            </table>
    
    
    
    </div>
    
    
    
    
</aura:component>
 
//Controller
({
returnAttList : function(component, event, helper) {

    var actionImage = component.get("c.getImage");
   /* actionImage.setParams({
        parentId : component.get("v.actId")
    });*/

    actionImage.setCallback(this, function(a){
        var lsa=a.getState();
        
        if(lsa==="SUCCESS"){
        component.set("v.atlist",a.getReturnValue());
            console.log('Peace');
            console.log('LSA1 >>>>'+lsa);
      
        }
        else if(lsa==="ERROR"){
            var error=response.getError();
            console.log('LSA2 >>>>'+lsa);
            if(errors){
                if(errors[0] && errors[0].message){
                    console.log(errors[0].message);
                    
                }
            }
            
        }
        
       /* var attach = a.getReturnValue();
        component.set("v.imageSrc", "/servlet/servlet.FileDownload?file=" + attach.Id);
        console.log('>>>>>>>>>'+attach); */
    });

    $A.enqueueAction(actionImage);
}

})
 
//ApexMethod
@AuraEnabled
	public static list<Attachment> getImage(){
        //Id parentId
    

    return [select Id, Name,Body, ContentType from Attachment 
            where parentid='0032800001EXXanAAH' and ContentType in ('image/png', 'image/jpeg', 'image/gif')];
}

Can someone tell me where i am going wrong because i am not able to display the list of attachments on the screen which is the primary step.
However, when i change it to any other sobject i am able todisplay those records on the screen.
 
Hi All,

I am working on converting a vf page to lightning component where i need to display error messages from a constructor.
//Following is the code in the constructor
 catch(exception ex){
        ApexPages.addmessage(new ApexPages.Message(ApexPages.Severity.ERROR,String.ValueOf(ex)));// This is for vf
        
    }

The above code works in VF. But, how do i display the message in a lightning component?

Thanks and Regards,
Bharath Kumar M
Hi All,

I am working on a requirement where we need to show the columns in a vf page based on the selected values in a multiselect picklist.
Below is the mock for the same.
User-added image
Any help on this would be greatly appreciated. We have completed one half of the thing but we are stuck with errors will be posting the code soon.

Thanks and Regards,
Bharath Kumar M
 

Hi All,

I am working on a requirement where the metadata type of the field is datetime and is used in several places. However, in one of the vf pages i need to show only the "date" which needs to be extracted from datetime.

Here's what i tried :
1.) Assign the value from datetime field to a string variable to get the substring.(NOT possible to assign datetime to string)
2.)Assign the value from datetime to date. In this case i get a totally different date value i.e with a difference of almost a month.
Below is the snippet for the same.
 

datetime finishDatetime;// datetime
date finishDate; // date only


finishDatetime= sr.CKSW_BASE__Finish__c;
finishDate=finishDatetime.date();   //This gives me the value of Feb 28th when converted to date along with a string of 0's and GMT where as the original value in the backend is around March 15th.

Any suggestions would be greatly helpful.


Thanks and Regards,
Bharath Kumar M
Hi All,

I tried adding the below piece of code to   the communitieslogin  and sitelogin vf page . Tried several ways and went to help and solutions articles too but that doesn't help. Can someone please help me with adding html / vf tags to the vf page?
<apex:page id="loginPage" controller="CommunitiesLoginController" action="{!forwardToAuthPage}" title="{!$Label.site.site_login}">

 <!--Start - Added by bharath
Below are the lines of code i tried to add
-->
 <apex:outputPanel >
    <apex:outputtext value="For best experience use Google chrome"/>
    <a href="https://www.google.com/chrome/browser/desktop/index.html">Download Chrome</a>
    
    
    </apex:outputPanel> -->
          <!--End - Added by bharath-->

</apex:page>


================================
//Doesn't work in this either


<apex:page id="loginPage" showHeader="false" controller="SiteLoginController" title="{!$Label.site.site_login}">
  <apex:composition template="{!$Site.Template}">
    <apex:define name="body">  
      <center>
        <apex:panelGrid bgcolor="white" columns="1"> 
          <br/>
          <br/>
          <apex:panelGrid width="758" cellpadding="0" cellspacing="0" bgcolor="white" columns="1" styleClass="topPanelContainer"> 
            <br/>
            <apex:outputPanel layout="block" styleClass="topPanel">
              <apex:panelGrid width="758" cellpadding="0" cellspacing="0" bgcolor="white" columns="2"> 
                <apex:image url="{!URLFOR($Resource.SiteSamples, 'img/clock.png')}"/>
                <apex:panelGroup >
                  <br/>
                  <apex:outputText styleClass="title" value="{!$Label.site.login}"/>
                  <br/>
                  <c:SiteLogin id="siteLogin"/>
                  <br/>
                </apex:panelGroup>
              </apex:panelGrid> 
             </apex:outputPanel>
            <c:SitePoweredBy />
          </apex:panelGrid> 
          
          <!--Start - Added by bharath-->
   <!-- <apex:outputPanel rendered="{! IF(userAgent !='Chrome', true,false ) }">
    <apex:outputtext value="For best experience use Google chrome"/>
    <a href="https://www.google.com/chrome/browser/desktop/index.html">Download Chrome</a>
    
    
    </apex:outputPanel> -->
          <!--End - Added by bharath-->
          
       </apex:panelGrid>
      </center>
      <br/>
    </apex:define>
  </apex:composition>
</apex:page>

Thanks,
Bharath
Hi All,

I am implementing a custom search solution using SOSL and Typeahead.js
Below is my sosl query the result of screenshots and the problems i am facing.
FIND {043*} IN ALL FIELDS RETURNING CKSW_BASE__SERVICE__C(NAME)


User-added image
If i give 043* it doesn't display me record with number 43. However if i give 0*4 in query it displays results containing 43. Any suggestions on building a better search solution would be greatly appreciated.

Thanks and Regards,

Bharath Kumar M

Hi All,

Following is the debug log that i am getting 
(
//list item 1
AppointmentBookingSlot:[BestSlotGrades=(GradeSlotResult:[Grade=100.00000000000000000000000000000000000, HeaderText=ASAP, IconName=clock-o, IsYesOrNoObjective=false, NumberOfAppointmentsWithGrade100=1, Objective=null, ObjectiveRecordTypeName=Objective_Asap, RankInAppointments=1, Text=1486735200000], 
GradeSlotResult:[Grade=100, HeaderText=Minimize Travel, IconName=car, IsYesOrNoObjective=false, NumberOfAppointmentsWithGrade100=24, Objective=null, ObjectiveRecordTypeName=Objective_Minimize_Travel, RankInAppointments=1, Text=null], 
GradeSlotResult:[Grade=100, HeaderText=Preferred Resource, IconName=users, IsYesOrNoObjective=true, NumberOfAppointmentsWithGrade100=24, Objective=null, ObjectiveRecordTypeName=Objective_PreferredEngineer, RankInAppointments=1, Text=null]), Grade=100.000000000000000000000000000000, 
Interval=TimeInterval:[2017-02-10 09:00:00,2017-02-10 11:00:00], SORT_BY_DATE=SORT_BY_DATE, SORT_BY_GRADE=SORT_BY_GRADE, SORT_BY_NO_SORT=SORT_BY_NO_SORT, SortByObjective=null, m_sortBy=SORT_BY_DATE],


// list item 2
AppointmentBookingSlot:[BestSlotGrades=(GradeSlotResult:[Grade=98.85057471264367816091954022988505800, HeaderText=ASAP, IconName=clock-o, IsYesOrNoObjective=false, NumberOfAppointmentsWithGrade100=1, Objective=null, ObjectiveRecordTypeName=Objective_Asap, RankInAppointments=2, Text=1486742400000], 
GradeSlotResult:[Grade=100, HeaderText=Minimize Travel, IconName=car, IsYesOrNoObjective=false, NumberOfAppointmentsWithGrade100=24, Objective=null, ObjectiveRecordTypeName=Objective_Minimize_Travel, RankInAppointments=2, Text=null], GradeSlotResult:[Grade=100, HeaderText=Preferred Resource, IconName=users, IsYesOrNoObjective=true, NumberOfAppointmentsWithGrade100=24, Objective=null, ObjectiveRecordTypeName=Objective_PreferredEngineer, RankInAppointments=2, Text=null]), Grade=99.0804597701149425287356321839080, Interval=TimeInterval:[2017-02-10 11:00:00,2017-02-10 13:00:00], SORT_BY_DATE=SORT_BY_DATE, SORT_BY_GRADE=SORT_BY_GRADE, SORT_BY_NO_SORT=SORT_BY_NO_SORT, SortByObjective=null, m_sortBy=SORT_BY_DATE])

I need to obtain Interval=TimeInterval:[2017-02-10 11:00:00,2017-02-10 13:00:00] and display it on a vf page.
This is a list of object----> i.e a managed package class called "​AppointmentBookingSlot". How can i parse this? 
Can someone provide me the pseudocode (like which data structure should be used to segregate) on how to proceed?

Any inputs would be very much helpful to me.


Thanks and Regards,

Bharath Kumar M

 

Hi All,

Below is the mockup of what i am planning to implement.
The records are fetched and displayed on the vf page is cards like fashion. Any help/idea on how to implement this is greatly appreciated.
For Example: I need to display only 3 images/ records per row . How can i limit this?
User-added image

Thanks and Regards,

Bharath Kumar M

Hi All,

I am working on a requirement where i am supposed to select 1 record. Everything was working but i have performance issues.
public class RadioButtonTest {
public List<contact> selectcon{get;set;}
public integer listSize{get;set;}
public  List<contact> allcons{get;set;}
public Contact con{get;set;}
Public List<contact> getAllContacts()
{
     allcons = [Select Id,FirstName,LastName,Email,Phone from Contact limit 5];
    return allcons;
}    
Public void selectcon()
{
    String selcontactid = System.currentPagereference().getParameters().get('conid');
    con = [Select Id,FirstName,LastName,Email,Phone from Contact where Id=:selcontactid];
    selectcon =  new List<contact>();
    selectcon.add(con);
}

Public List<contact> getselectedContact()
{
if (selectcon!=null)
listSize=selectcon.size();

    return selectcon;
}
public void weeee(){
listSize=selectcon.size();

 try{
if(con.id==null || listSize==0){
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Invalid Input.');
            ApexPages.addMessage(myMsg);
}
else{
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.INFO,'Selected a contact');
            ApexPages.addMessage(myMsg);
system.debug(' Inside weeeeee'+selectcon);
}
}
catch(Exception e){ ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Invalid Input.');
            ApexPages.addMessage(myMsg);}
}

}


<apex:page controller="RadioButton" showheader="false">
<apex:form >
<apex:pageblock id="allcons" title="Available Contacts">
               <apex:pageblocktable id="allcons" value="{!AllContacts}" var="allcon">
                    <apex:column headervalue="Set as Primary">                    
                       <apex:actionsupport action="{!selectcon}" event="onclick" rerender="consel">  
                        <input type="radio" name="<strong>selectRadio</strong>"  />                    
                            <apex:param name="conid" value="{!allcon.Id}">
                        </apex:param></apex:actionsupport>                            
                    </apex:column>    
                    <apex:column headervalue="Last Name">
                        <apex:outputfield value="{!allcon.LastName}">
                    </apex:outputfield></apex:column> 
                    <apex:column headervalue="First Name">
                        <apex:outputfield value="{!allcon.FirstName}">
                    </apex:outputfield></apex:column>  
                    <apex:column headervalue="Email">
                        <apex:outputfield value="{!allcon.Email}">
                    </apex:outputfield></apex:column>  
                    <apex:column headervalue="Phone">
                        <apex:outputfield value="{!allcon.Phone}">
                    </apex:outputfield></apex:column>  
                </apex:pageblocktable>
</apex:pageblock> 
<apex:pageblock id="consel" title="Selected Contact">
            <apex:pageblocktable id="allcons" value="{!selectedContact}" var="selcon" >                       
                    <apex:column headervalue="Last Name">
                        <apex:outputfield value="{!selcon.LastName}">
                    </apex:outputfield></apex:column> 
                    <apex:column headervalue="First Name">
                        <apex:outputfield value="{!selcon.FirstName}">
                    </apex:outputfield></apex:column>  
                    <apex:column headervalue="Email">
                        <apex:outputfield value="{!selcon.Email}">
                    </apex:outputfield></apex:column>  
                    <apex:column headervalue="Phone">
                        <apex:outputfield value="{!selcon.Phone}">
                    </apex:outputfield></apex:column>  
                </apex:pageblocktable>
</apex:pageblock>               
</apex:form>
</apex:page>


User-added image
When i select a contact the below section i.e selected contact gets rerendered. It is only then that i get the "selected contact's id" which will be used for further processing. But there's a lag of 1.8 seconds roughly (before which the selected contact id will be null) 
Any suggestions on improving the performance is greatly appreciated.


Thanks,

Bharath

Hi All,

I am working on a project and in the data model i can see "Created By and Last modified By" for some objects and "Created By, Last modified By and Owner name" for some objects(all are standard fields). May i ask you that on what basis are the owner fields added?(In general context)

Thanks and Regards,
Bharath Kumar M

Hi All,

Following is my data model :

Event (Custom) ---> Child--->Grandchild

My requirement is to send an email alert to a user in a lookup of grandchild WHEN either a "Parent,Child or Grandchild is updated".
Any help on achieving this with a single trigger/workflow is greatly appreciated.(I believe we need to use more than one trigger /workflow for this)
 

Hi All,

I have a situation where i need to insert 2 fields from account and the few fields from contact(related to account) to a custom object . Is it possible using triggers?
 

Hi All,

I have a scenario where Person A and Person B are 2 helpdesk representatives who login using partner community portal.
Person A should not be able to view "Cases" assigned to Person B and vice versa.
How can i achieve this?
 

Hi All,

I am working on a PoC where i am consuming data from an external servcie and displaying it on a VF page.
Can someone let me know where i am going wrong and what needs to be done to display the data on the VF page.
public class TickerData {
	
	public list<Prices> pricelist{get;set;}
    private static String endpoint='https://koinex.in/api/ticker';
    
    public list<Prices> getmakeTickerData(){
		
		
		pricelist = new list<Prices>();
        Http http= new Http();
        HttpRequest request= new HttpRequest();
        request.setendpoint(endpoint);
        request.setMethod('GET');
        HttpResponse response = http.send(request); //response contains json body
        
        if(response.getStatusCode()==200){
            system.debug('Response'+response.getBody());
            //JSON2Apex js=JSON2Apex.parse(response.getBody());
            JSONParser parser = JSON.createParser (response.getBody()); 
   			while (parser.nextToken()!=null) { 
                if (parser.getCurrentToken()== JSONToken.START_ARRAY) {    
                    while (parser.nextToken()!= null) { 
                        
                        //
			if(response.getstatusCode() == 200 && response.getbody() != null){

				pricelist=(List<Prices>)json.deserialize(response.getbody(),List<Prices>.class);

			}//
                        /*if (parser.getCurrentToken()== JSONToken.START_OBJECT) { 
                            JSON2Apex the = (JSON2Apex) parser.readValueAs (JSON2Apex.class); 
                        }*/
                  }
            }
			
			
            //Map<String,Object> results=(Map<String,Object>)JSON.deserializeUntyped(response.getBody());
            /*List<Object> prices=(List<Object>)results.get('prices');
            
            for(Object o:prices){
                System.debug('Prices :'+o);
                
            }*/
        	}
        
    	}
        return pricelist;
	}


	public class Prices {
		public String BTC{get;set;}
		public String ETH{get;set;}
		public String XRP{get;set;}
		public String BCH{get;set;}
		public String LTC{get;set;}
		public String NEO{get;set;}
		public Double MIOTA{get;set;}
		public String TRX{get;set;}
		public String OMG{get;set;}
		public String AE{get;set;}
		public String ZRX{get;set;}
		public String GAS{get;set;}
		public String BAT{get;set;}
		public String GNT{get;set;}
		public String REQ{get;set;}
		public String AION{get;set;}
		public String NCASH{get;set;}
		public String XLM{get;set;}
	}
	
    public class JSON2Apex {
		public Prices prices;
		public Stats stats;
	}
    
	public Prices prices;
	public Stats stats;

	public class ETH {
		public String currency_full_form;
		public String currency_short_form;
		public String per_change;
		public Double last_traded_price;
		public String lowest_ask;
		public String highest_bid;
		public String min_24hrs;
		public String max_24hrs;
		public Integer vol_24hrs;
	}

	public class Stats {
		public ETH ETH;
		public ETH BTC;
		public ETH LTC;
		public ETH XRP;
		public ETH BCH;
		public ETH OMG;
		public ETH REQ;
		public ETH ZRX;
		public ETH GNT;
		public ETH BAT;
		public ETH AE;
		public ETH TRX;
		public ETH XLM;
		public ETH NEO;
		public ETH GAS;
		public ETH NCASH;
		public ETH AION;
	}

}
 
VF Page :

<apex:page controller="TickerData">
<apex:form>

<apex:pageBlock >

<apex:pageBlockTable value="{!makeTickerData}" var="wrap" width="100%">
<apex:column headerValue="BTC" value="{!wrap.BTC}"/>
<apex:column headerValue="ETH" value="{!wrap.ETH}"/>
</apex:pageBlockTable>

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

 
Hi,

I need to design approval process we need to send approval for 5 users, 
If 1st user accepts then it need to more 2nd approval then 3rd then 4th then 5th
if any one reject that need to move back 
ex: if 3th rejects need to go to 2nd to approval.

How can we acheive these ?
I cannot complete the challenge in my playground because in the previous module where Knowledge was enabled, the Enable Lightning Knowledge  setting was defaulted to checked, and no instructions specifically indicated to make sure it was unchecked. Now, the steps in the next module cannot be completed. What should I do to move forward?
I have a vf page where i want to add rows every time "add  row" button is clicked..but i am facing some error..when a new row is created previous row's values are automatically copied ..
here is my controller class-
public class SayanTest{
public Service_Type__c acc{get;set;}
public Service_Request__c sr{get;set;}
public Service_Line_Item__c slt;
public List<Service_Line_Item__c> cont{get;set;}
//public List<Work_Order__c> wo{get;set;}
public List<Work_Order__c> wod=new List<Work_Order__c>();
public List<Service_Type__c > accl{get;set;}
//public List<Service_Line_Item__c> cont1{get;set;}
public Boolean showBank{get;set;}
public Boolean showCard{get;set;}
public Boolean showOther{get;set;}
public Boolean showTransfer{get;set;}
public boolean displayPopup {get; set;} 
public boolean flag1 {get;set;}
public String selected {get;set;}
public Boolean tenkservice{get;set;}
public Boolean engineoiltype{get;set;}
public Boolean clutchtype{get;set;}
public Boolean tyretype{get;set;}
public Boolean fanbelt{get;set;}
public Boolean coolant{get;set;}
public Boolean newRow{get;set;}
public Boolean estimation{get;set;}
public Decimal engrate{get;set;}
public Decimal clutchrate{get;set;}
public Decimal tyrerate{get;set;}
public Decimal fanrate{get;set;}
public Decimal coolrate{get;set;}
public Decimal englbr{get;set;}
public Decimal clutchlbr{get;set;}
public Decimal tyrelbr{get;set;}
public Decimal fanlbr{get;set;}
public Decimal coollbr{get;set;}
public Decimal allRateSpare{get;set;}
public Decimal allRateLabour{get;set;}
public Decimal sum{get;set;}
public Decimal count{get;set;}
public Decimal total{get;set;}
public Boolean tyrecount;
public Boolean engcount;
public Boolean clutchcount;
public Boolean fanbeltcount;
public Boolean coolantcount;
public Boolean oilfiltertype{get;set;}
public Decimal s;
public decimal engspare;
public Decimal englabour;
public Decimal engqty{get;set;}
public Decimal englbrqty{get;set;}
public Decimal clutchspare;
public Decimal clutchlabour;
public Decimal clutchspareqty{get;set;}
public Decimal clutchlbrqty{get;set;}
public Decimal tyrespare;
public Decimal tyrelabour;
public Decimal tyrespareqty{get;set;}
public Decimal tyrelbrqty{get;set;}
public Decimal fanbeltspare;
public Decimal fanbeltlabour;
public Decimal fanbeltspareqty{get;set;}
public Decimal fanbeltlbrqty{get;set;}
public Decimal coolantspare;
public Decimal coolantlabour;
public Decimal coolantspareqty{get;set;}
public Decimal coolantlbrqty{get;set;}
public Decimal allspare;
public Decimal alllabour;
public Decimal allspareqty{get;set;}
public Decimal alllbrqty{get;set;}
public Decimal oilfilterspareqty{get;set;}
public Decimal oilfiltersparerate{get;set;}
public Decimal oilfilterlabourqty{get;set;}
public Decimal oilfilterlabourrate{get;set;}
public Integer jobcount;
public Integer i=0;
public SayanTest(ApexPages.StandardController controller) { 
 acc= (Service_Type__c)controller.getRecord();
showBank = false;
      showCard = false;
      showTransfer = false;
      tenkservice=false;
      engineoiltype=false;
      clutchtype=false;
      tyretype=false;
      fanbelt=false;
      coolant=false;
      showOther=false;
      newRow=false;
      estimation=false;
      sum=0;
      s=0;
      count=0;
      total=0;
      engcount=false;
      clutchcount=false;
      engrate=0;
      clutchrate=0;
      tyrerate=0;
      fanrate=0;
      coolrate=0;
      allRateSpare=0;
      englbr=0;
      clutchlbr=0;
      tyrelbr=0;
      fanlbr=0;
      coollbr=0;
      allRateLabour=0;
      tyrecount=false;
      fanbeltcount=false;
      coolantcount=false;
      engspare=0;
      englabour=0;
      clutchspare=0;
      clutchlabour=0;
      tyrespare=0;
      tyrelabour=0;
      fanbeltspare=0;
      fanbeltlabour=0;
      engqty=0;
      englbrqty=0;
      clutchspareqty=0;
      clutchlbrqty=0;
      tyrespareqty=0;
      tyrelbrqty=0;
      fanbeltspareqty=0;
      fanbeltlbrqty=0;
      coolantspareqty=0;
      coolantlbrqty=0;
      allspare=0;
      allspareqty=0;
      alllabour=0;
      alllbrqty=0;
      jobcount=0;
           
    acc = new Service_Type__c ();
    cont = new List<Service_Line_Item__c>();
    accl=new List<Service_Type__c >();
   // wo=new List<Work_Order__c>();
   //wod=new Work_Order__c();
    //cont1= new List<Service_Line_Item__c>();
   // slt=new Service_Line_Item__c();
   
    AddRow();
   

}
public PageReference  AddRow(){
//Service_Type__c  s=new Service_Type__c ();
 Service_Line_Item__c sli=new Service_Line_Item__c();
    cont.add(sli);
   
    
    return null;
}


   
   

}
Hi All,

I am working on converting a vf page to lightning component where i need to display error messages from a constructor.
//Following is the code in the constructor
 catch(exception ex){
        ApexPages.addmessage(new ApexPages.Message(ApexPages.Severity.ERROR,String.ValueOf(ex)));// This is for vf
        
    }

The above code works in VF. But, how do i display the message in a lightning component?

Thanks and Regards,
Bharath Kumar M

Hi All,

I am working on a requirement where the metadata type of the field is datetime and is used in several places. However, in one of the vf pages i need to show only the "date" which needs to be extracted from datetime.

Here's what i tried :
1.) Assign the value from datetime field to a string variable to get the substring.(NOT possible to assign datetime to string)
2.)Assign the value from datetime to date. In this case i get a totally different date value i.e with a difference of almost a month.
Below is the snippet for the same.
 

datetime finishDatetime;// datetime
date finishDate; // date only


finishDatetime= sr.CKSW_BASE__Finish__c;
finishDate=finishDatetime.date();   //This gives me the value of Feb 28th when converted to date along with a string of 0's and GMT where as the original value in the backend is around March 15th.

Any suggestions would be greatly helpful.


Thanks and Regards,
Bharath Kumar M
Hi All,

I tried adding the below piece of code to   the communitieslogin  and sitelogin vf page . Tried several ways and went to help and solutions articles too but that doesn't help. Can someone please help me with adding html / vf tags to the vf page?
<apex:page id="loginPage" controller="CommunitiesLoginController" action="{!forwardToAuthPage}" title="{!$Label.site.site_login}">

 <!--Start - Added by bharath
Below are the lines of code i tried to add
-->
 <apex:outputPanel >
    <apex:outputtext value="For best experience use Google chrome"/>
    <a href="https://www.google.com/chrome/browser/desktop/index.html">Download Chrome</a>
    
    
    </apex:outputPanel> -->
          <!--End - Added by bharath-->

</apex:page>


================================
//Doesn't work in this either


<apex:page id="loginPage" showHeader="false" controller="SiteLoginController" title="{!$Label.site.site_login}">
  <apex:composition template="{!$Site.Template}">
    <apex:define name="body">  
      <center>
        <apex:panelGrid bgcolor="white" columns="1"> 
          <br/>
          <br/>
          <apex:panelGrid width="758" cellpadding="0" cellspacing="0" bgcolor="white" columns="1" styleClass="topPanelContainer"> 
            <br/>
            <apex:outputPanel layout="block" styleClass="topPanel">
              <apex:panelGrid width="758" cellpadding="0" cellspacing="0" bgcolor="white" columns="2"> 
                <apex:image url="{!URLFOR($Resource.SiteSamples, 'img/clock.png')}"/>
                <apex:panelGroup >
                  <br/>
                  <apex:outputText styleClass="title" value="{!$Label.site.login}"/>
                  <br/>
                  <c:SiteLogin id="siteLogin"/>
                  <br/>
                </apex:panelGroup>
              </apex:panelGrid> 
             </apex:outputPanel>
            <c:SitePoweredBy />
          </apex:panelGrid> 
          
          <!--Start - Added by bharath-->
   <!-- <apex:outputPanel rendered="{! IF(userAgent !='Chrome', true,false ) }">
    <apex:outputtext value="For best experience use Google chrome"/>
    <a href="https://www.google.com/chrome/browser/desktop/index.html">Download Chrome</a>
    
    
    </apex:outputPanel> -->
          <!--End - Added by bharath-->
          
       </apex:panelGrid>
      </center>
      <br/>
    </apex:define>
  </apex:composition>
</apex:page>

Thanks,
Bharath
Hi All,

Following is the debug log that i am getting 
(
//list item 1
AppointmentBookingSlot:[BestSlotGrades=(GradeSlotResult:[Grade=100.00000000000000000000000000000000000, HeaderText=ASAP, IconName=clock-o, IsYesOrNoObjective=false, NumberOfAppointmentsWithGrade100=1, Objective=null, ObjectiveRecordTypeName=Objective_Asap, RankInAppointments=1, Text=1486735200000], 
GradeSlotResult:[Grade=100, HeaderText=Minimize Travel, IconName=car, IsYesOrNoObjective=false, NumberOfAppointmentsWithGrade100=24, Objective=null, ObjectiveRecordTypeName=Objective_Minimize_Travel, RankInAppointments=1, Text=null], 
GradeSlotResult:[Grade=100, HeaderText=Preferred Resource, IconName=users, IsYesOrNoObjective=true, NumberOfAppointmentsWithGrade100=24, Objective=null, ObjectiveRecordTypeName=Objective_PreferredEngineer, RankInAppointments=1, Text=null]), Grade=100.000000000000000000000000000000, 
Interval=TimeInterval:[2017-02-10 09:00:00,2017-02-10 11:00:00], SORT_BY_DATE=SORT_BY_DATE, SORT_BY_GRADE=SORT_BY_GRADE, SORT_BY_NO_SORT=SORT_BY_NO_SORT, SortByObjective=null, m_sortBy=SORT_BY_DATE],


// list item 2
AppointmentBookingSlot:[BestSlotGrades=(GradeSlotResult:[Grade=98.85057471264367816091954022988505800, HeaderText=ASAP, IconName=clock-o, IsYesOrNoObjective=false, NumberOfAppointmentsWithGrade100=1, Objective=null, ObjectiveRecordTypeName=Objective_Asap, RankInAppointments=2, Text=1486742400000], 
GradeSlotResult:[Grade=100, HeaderText=Minimize Travel, IconName=car, IsYesOrNoObjective=false, NumberOfAppointmentsWithGrade100=24, Objective=null, ObjectiveRecordTypeName=Objective_Minimize_Travel, RankInAppointments=2, Text=null], GradeSlotResult:[Grade=100, HeaderText=Preferred Resource, IconName=users, IsYesOrNoObjective=true, NumberOfAppointmentsWithGrade100=24, Objective=null, ObjectiveRecordTypeName=Objective_PreferredEngineer, RankInAppointments=2, Text=null]), Grade=99.0804597701149425287356321839080, Interval=TimeInterval:[2017-02-10 11:00:00,2017-02-10 13:00:00], SORT_BY_DATE=SORT_BY_DATE, SORT_BY_GRADE=SORT_BY_GRADE, SORT_BY_NO_SORT=SORT_BY_NO_SORT, SortByObjective=null, m_sortBy=SORT_BY_DATE])

I need to obtain Interval=TimeInterval:[2017-02-10 11:00:00,2017-02-10 13:00:00] and display it on a vf page.
This is a list of object----> i.e a managed package class called "​AppointmentBookingSlot". How can i parse this? 
Can someone provide me the pseudocode (like which data structure should be used to segregate) on how to proceed?

Any inputs would be very much helpful to me.


Thanks and Regards,

Bharath Kumar M

 

Hi All,

I am working on a requirement where a method returns value and that value is used by some other method. But the method is returning object from which i am not able to get any values. How can i convert the object to string? Tried type casting but i am not able to do it.
public static object getCandidates(string serviceId )
   {
        
                CKSW_SRVC.GradeSlotsService candidatesService =         new CKSW_SRVC.GradeSlotsService(getCandidatesSchedulePolicyId(), serviceId)  ;
                system.debug('elad'+candidatesService);
                CKSW_SRVC.AdvancedGapMatrix candidates = candidatesService.GetGradedMatrix(false);
                System.debug('candidates  :: '+candidates );
             
                return candidates;
   }


Debug log received :

//As you can observe the debug log i get is returning values with flower braces in between and not in the beginning so i am not able to extract values from it.

15:40:15:745 USER_DEBUG [1056]|DEBUG|candidates  :: AdvancedGapMatrix:[CPUTimeTook=301, CurrentTime=2017-01-20 10:10:00, ResourceIDToScheduleData={a0Z6C000000ClQuUAK=ResourceScheduleData:[AdditionalObjects=null, CurrentSlotsIndexInAB=0, Resource=CKSW_BASE__Resource__c:{Id=a0Z6C000000ClQnUAK, Name=Test_FT1, CKSW_BASE__Location__c=a0F6C0000008kO2UAI, CKSW_BASE__Contractor__c=false, CKSW_BASE__Active__c=true}, SchedulingOptions=()], a0Z6C000000ClRHUA0=ResourceScheduleData:[AdditionalObjects=null, CurrentSlotsIndexInAB=0, Resource=CKSW_BASE__Resource__c:{Id=a0Z6C000000ClRHUA0, Name=Field Tech 1, CKSW_BASE__Location__c=a0F6C0000008kO2UAI, CKSW_BASE__Contractor__c=false, CKSW_BASE__Active__c=true}, SchedulingOptions=()], a0Z6C000000ClRMUA0=ResourceScheduleData:[AdditionalObjects=null, CurrentSlotsIndexInAB=0, Resource=CKSW_BASE__Resource__c:{Id=a0Z6C000000ClRMUA0, Name=Field Tech 2, CKSW_BASE__Location__c=a0F6C0000008kO2UAI, CKSW_BASE__Contractor__c=false, CKSW_BASE__Active__c=true}, SchedulingOptions=()], a0Z6C000000DykdUAC=ResourceScheduleData:[AdditionalObjects=null, CurrentSlotsIndexInAB=0, Resource=CKSW_BASE__Resource__c:{Id=a0Z6C000000DykdUAC, Name=Field Tech 3, CKSW_BASE__Location__c=a0F6C0000008kO2UAI, CKSW_BASE__Contractor__c=false, CKSW_BASE__Active__c=true}, SchedulingOptions=()], a0Z6C000000E2DpUAK=ResourceScheduleData:[AdditionalObjects=null, CurrentSlotsIndexInAB=0, Resource=CKSW_BASE__Resource__c:{Id=a0Z6C000000E2DpUAK, Name=Field Tech 4, CKSW_BASE__Location__c=a0F6C0000008kO2UAI, CKSW_BASE__Contractor__c=false, CKSW_BASE__Active__c=true}, SchedulingOptions=()]}, Service=CKSW_BASE__Service__c:{Id=a0n6C0000009sURQAY, Name=S-0709, CKSW_BASE__Resource__c=a0Z6C000000DykdUAC, CKSW_BASE__Location__c=a0F6C0000008kO2UAI, CKSW_BASE__Early_Start__c=2017-01-12 12:15:00, CKSW_BASE__Due_Date__c=2017-01-13 21:35:00, CKSW_BASE__Start__c=2017-01-12 16:00:00, CKSW_BASE__Finish__c=2017-01-12 17:30:00, CKSW_BASE__Duration__c=1.50, CKSW_BASE__Duration_Type__c=Hours, CKSW_BASE__Geolocation__Latitude__s=37.806308, CKSW_BASE__Geolocation__Longitude__s=-77.852860, CKSW_BASE__Appointment_Start__c=2017-01-12 16:00:00, CKSW_BASE__Appointment_Finish__c=2017-01-12 18:00:00, CKSW_BASE__Same_Resource__c=false, CKSW_BASE__Same_Day__c=false}]


//I expect the ABOVE debug log to appear in the below format i.e which generally displays list values when debugged. 
15:40:15:750 USER_DEBUG [10]|DEBUG|List of acc(Account:{Id=0016C000003xBCDQA2, Name=Mintus, RecordTypeId=01236000000nZNeAAM}, Account:{Id=0016C000002ZtrgQAC, Name=test, RecordTypeId=01236000000nZNeAAM}, Account:{Id=0016C000002ZyIaQAK, Name=ACME, RecordTypeId=01236000000nZNeAAM}, Account:{Id=0016C000002t9mQQAQ, Name=Reliance, RecordTypeId=0126C00000005xXQAQ}, Account:{Id=0016C000002XuCxQAK, Name=First Services Provider Account, RecordTypeId=01236000000nZNeAAM})

Any suggestions/ solutions on this would be of great help.

Thanks and Regards,
Bharath
<apex:page controller="onaccountdata">
    <apex:form id="out">
        <apex:pageBlock title="Account">
            <apex:pageBlockSection >
                <apex:inputtext label="Account Name" value="{!enteredname}"/>
                <apex:commandButton value="Click" action="{!getcontacts}" reRender="out"/>
                <apex:inputtext label="Industry" value="{!industry}"/>
            </apex:pageBlockSection>
        </apex:pageBlock> 
        <apex:outputPanel id="e">{!error}</apex:outputPanel>
        <apex:pageBlock title="Contacts"> 
            <apex:commandButton value="save" action="{!customsave}" reRender="e"/>
            <apex:pageblockSection >
                <apex:inputtext label="First Name" value="{!firstname}"/>
                <apex:inputtext label="Last Name" value="{!lastname}"/>
                <apex:inputtext label="Phone" value="{!phone}"/>
                <apex:inputtext label="Email" value="{!email}"/>
            </apex:pageblockSection>
        </apex:pageBlock>   
    </apex:form>
</apex:page>

================================================================================================

public class onaccountdata 
{

    public onaccountdata() {

    }


    public onaccountdata(ApexPages.StandardController controller) {

    }

    public string enteredname{get; set;}
    public string industry {get; set;}
    public string firstname{get; set;}
    public string lastname{get; set;}
    public string phone{get; set;}
    public string email{get; set;}
    public exception error{get; set;}
    public contact con{get;set;}

    public void getcontacts()
    {
        account acc = [select id, name, industry from account where name =: enteredname limit 1];
        con = [select id, firstname, lastname, phone, email from contact where accountid =: acc.id limit 1];
        industry = acc.industry;
        firstname = con.firstname;
        lastname = con.lastname;
        phone = con.phone;
        email = con.email;
    }
    
    public void customsave()
    {   
        if(con.id != null && con.id != '')
        {
           con.firstname = firstname;
           con.lastname = lastname;
           con.phone = phone;
           con.email = email;
           try
           {
           update con; 
            }
            catch (exception ex)
            {
                error = ex;
              
            }
        }
        
        else
        {
            contact con = new contact();
            con.firstname = firstname;
            con.lastname = lastname;
            con.phone = phone;
            con.email = email;
            try 
            {
            insert con;
            }
            catch (exception ex)
            {
                error = ex;
            }
        }
    }
}​
We integrate pdf's into a junction salesforce object called PDF_Uploader__c, then I have a before insert trigger that creates a record(AS400_Report__c) from the attachment name and then moves the attachment to the newly created record. If I attach the pdf manually one at a time, the trigger works perfectly. If I use our integration system(Jitterbit) and try to insert 2 attachments, it creates two records from only one of the attachments, instead of creating two records with an attachment in each. I user a master trigger and trigger handler class to accomplish this. What am I doing wrong?
public void createAS400ReportRecord(){
        List<AS400_Report__c> reportList = new List<AS400_Report__c>();
        Map<Id,AS400_Report__c> reportMap = new Map<Id,AS400_Report__c>();
        string attachmentNameWithoutExtension = '';
        list<string> splitList = new list<string>();
        Set<String>reportKeySet = new Set<String>();
    	List<AS400_Report__c> recordsToCreate = new List<AS400_Report__c>();
        Attachment a;
        
        for(sObject sObj : Trigger.new){
            a = (Attachment)sObj;
            if(string.isBlank(a.Name)){
				continue;
            }
        if(a.ParentId.getSObjectType() == PDF_Uploader__c.getSObjectType() && a.Description == 'AS400 Documents'){
                system.debug('In Loop1: ' + a.Name);
                splitList = a.Name.split('\\.'); //Need to get rid of .pdf
                attachmentNameWithoutExtension = splitList[0];
                 reportKeySet.add(attachmentNameWithoutExtension);  
            
        system.debug('In Loop2: ' + splitList[0]);
            }
            //system.debug(a.Name);
        }
        
        for(sObject sObj : Trigger.new){
            a = (Attachment)sObj;
                AS400_Report__c report = new AS400_Report__c();
            	report.Name = attachmentNameWithoutExtension;
                report.Status__c = 'New';
                report.Created_Date_Time__c = date.Today();            
                reportList.add(report);
            system.debug(report.Name);
        }
        insert reportList;
        system.debug(reportList.size());
            //2. Query the report from the set created above
            reportList = [SELECT Id,Name
                           FROM AS400_Report__c
                          Where Name = :reportKeySet];
        	system.debug('Report Size: ' + reportList.size());
    
    		//3. Loop through the reports and create map of key
            Map<String,AS400_Report__c> mapreport = new Map<String,AS400_Report__c>();
            for(AS400_Report__c r : reportList){
                Mapreport.put(r.Name,r);
            }
           //4.Loop thorugh attachments and use the map above to cop attachment
            for(sObject sObj : Trigger.new){
                a = (Attachment)sObj;
                if(string.isBlank(a.Name)){
                    continue;
                }
                if(a.ParentId.getSObjectType() == PDF_Uploader__c.getSObjectType()){
                    splitList = a.Name.split('\\.'); //Need to get rid of .pdf
                	attachmentNameWithoutExtension = splitList[0];
                    if(Mapreport.containsKey(attachmentNameWithoutExtension)){
                        a.ParentId = mapreport.get(attachmentNameWithoutExtension).Id;
                    }
                    system.debug(a.ParentId);
                }
            } 
    }

 

Hi All,

I recently came across this piece of code on the net when i was searching for something and it goes like this :

public Attachment fileContent {get {
                                               if(fileContent == null) {
                                                       fileContent = new Attachment();
                                               } 
                                               return fileContent;
                                       }  //This block of code is my concern

set; }

What is the advantage of using a condition here vs using the same condition in a method to check if the file is null or not?

Thanks and Regards,

Bharath

Our notes & attchemnet are accessible through files(ie ContentDocumentLink replacement of attachment object), As we can not access/get attachment through lightning experience.
reference: https://help.salesforce.com/apex/HTViewSolution?urlname=Attachments-are-not-returned-in-Lightning-Experience-search&language=en_US
I want to display the attachment(image file) on lightning component, How can I display it?
I tried following code :
<apex:image url="/servlet/servlet.FileDownload—file=06941000000SKtyAAG" width="50" height="50" />  
 <apex:image url="/servlet/servlet.FileDownload?file={!attchmentId}"/>

 

Hi All,

I have written a trigger which is used to insert the status changes on an object. i.e there are multiple updates on an object and i need to do the following :

1.)insert a record into the new object when "Availability time is changed"
2.)insert when the "status" of a object is changed.
For each change i need one instance to be created with appropriate values for time and status change
But the trigger acts roguely. sometimes it creates a record and sometimes it waits for another trigger which will create an object in the table and then fire multiple times. How can i stop this recursive behaviour of the trigger?
Can someone please look into the below code suggest the changes :

trigger UpdateHistoryStatusOnService on WorkOrder (After update) {
 
Service_Status_History__c statusobj = new Service_Status_History__c(); //the object in which a record should be inserted
    List<WorkOrder > liserv = [select id, name , Financial_Status__c, Package_Decline_Reason__c,packagecomments__c,Timechange_comments__c,Timechange_Reason__c, Workorder_Status__c from WorkOrder where id in : Trigger.new];
    list<Service_Status_History__c> hlist= new list<Service_Status_History__c>();

   
    for(WorkOrder s : liserv){
         
        if(s.Financial_Status__c == 'Package Submitted' || s.Financial_Status__c == 'Package Declined' ){
            statusobj.Name = 'Package';
            statusobj.Service__c = s.id;
            if(s.Financial_Status__c == 'Package Declined' ){
                if(s.Package_Decline_Reason__c != null || s.packagecomments__c!= null)
                {
                    statusobj.Reason_Code__c = s.Package_Decline_Reason__c ;
                    statusobj.Comment__c = s.packagecomments__c;
                     statusobj.Previous_Status__c= trigger.oldmap.get(s.id).Financial_Status__c ;
                     statusobj.New_Status__c = s.Financial_Status__c ;
					 //insert the record with presentstatus, previous status, reason code and comments 
                }   
           
            //hlist.add(statusobj);
            
        }
        else if (s.Financial_Status__c =='Package Approved'){
            statusobj.Previous_Status__c= trigger.oldmap.get(s.id).Financial_Status__c ;
            statusobj.New_Status__c = s.Financial_Status__c ;
           //insert when package approved
           
        }
          /*  else if (s.Financial_Status__c =='Package Submitted'){
            statusobj.New_Status__c = s.Financial_Status__c ;
           
           
        }*/
     
      
        
    }
    else {
      }
     
      
      if(s.Timechange_comments__c!= null  && s.Timechange_Reason__c!= null ){
       statusobj.Name = 'Time Availability';
       statusobj.Reason_Code__c = s.Timechange_Reason__c;
       statusobj.Comment__c = s.Timechange_comments__c;
       statusobj.New_Status__c = s.Workorder_Status__c ;
       //hlist2.add(statusobj);
      //  insert hlist2;
	  //Insert when availability time is changed
     } 
   
    
 
}
   
    hlist.add(statusobj);
    insert hlist;
}
 

Thanks,

Bharath

Hi All,

Below is the piece of code which is executing in salesforce platform(flawlessly) but not in communities(When i execute the below code in communities i am able to get a javascript alert and nothing beyond that). Would be glad if someone can tell me where im going wrong.
{!REQUIRESCRIPT("/soap/ajax/34.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/34.0/apex.js")}



var p = new sforce.SObject('Deal__c');
p.id = "{!Deal__c.Id}";


function fixTime(time){
   if(time < 10) {time = "0" + time};
   return time;
}

function fixDate(date){
  var Month = fixTime(date.getMonth() + 1);
  var Day = fixTime(date.getDate());
  var UTC = date.toUTCString();
  var Time = UTC.substring(UTC.indexOf(':')-2, UTC.indexOf(':')+6);

  var Minutes = fixTime(date.getMinutes());
  var Seconds = fixTime(date.getSeconds());
  return date.getFullYear() + "-" + Month + "-" + Day + "T" + Time;
}
 
var oldStat = "{!Deal__c.Status__c}";
if(oldStat == 'Closed'){
alert(' This deal is already closed ');

}
else{
p.Status__c = "Closed";
p.End_date__c = fixDate(new Date()); 
var result = sforce.connection.update([p]);
window.location.reload();
}


Thanks,

Bharath
 

Hi All,

I have written a trigger which will supply the location details to a vf page. How can i create a test class for such a trigger?

trigger SetAssetLocation on Asset (after insert, after update) {
    for (Asset a : trigger.new)
        if (a.Location__Latitude__s == null)
            AssetLocation.getLocations(a.id);
    

}
How to write a test class for a page with only one lookup field and an action submit(No DML operations involved). On submit the data from the lookup field is passed to another controller to perform a search operation using SOQL and not SOSL

Hi All,

Can someone give me the logic to write a trigger to update a parent object's comment field when a child object's comment field is updated.
 

HI Everyonce,

Can anyone let me know how to integrate medical devices with salesforce using any middleware tools.
Hi All,

I have created login form with username and passsword.I have created new custom fields in the contact object.
On click of submit button.It will validates the contact is existing or not and returns contact's FirstName,LastName,Email,Phone.

For this I created a RESTAPI which will take the username and password as a parameters and validates against the credentials and  returns the contact details for that valid user.Login form i have created in my org. using lightning.

Now my challenge is  when the user clicks on submit button it should get the contact details from the RESTAPI and maps with the contact object fields and   reload or refresh the page with contact details and displays the field values FirstName,LastName,Email and Phone.
I am trying to pass the variables or map the variables which are returned from REST API to APEX.

How can I acheive this scenario.Do I need to create another lightning component to refresh the parent component to child component and returns the login contact details.

If anyone can provide a sample code that would be a great help.

Any help would be greatly appreciated.

Thanks,
Sirisha
Looking for best REST API to upload a file to a record with at least file size 100MB?
 
I have created custom REST API handles POST call, inserts both ContentVersion, ContentDocumentLink records (Base 64 content in request body) manually. But using custom API not able to upload(not able to test) file size more than 23 MB.
 
other way using with standard salesforce REST API, (/services/data/v35.0/chatter/feed-elements)issue is, It's not supporting Base 64 binary data conversion to normal format..

But in salesforce developer guide docs, mentioned that file size limit to upload REST API is 2 GB.
(Copied same lines, links from the articles).
 
  • maximum file size for uploads is 2 GB for ContentVersion objects”,
  • To upload a binary file up to 2 GB (including headers) ”,
  • “Salesforce CRM Content
  • Content and Libraries tabs in Salesforce Classic
  • 2 GB
  • 2 GB (including headers) when uploaded via Chatter REST API
  • 2 GB (including headers) when uploaded via REST API

 
 
 
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_insert_update_blob.htm
 
https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/intro_input.htm
 
https://help.salesforce.com/articleView?id=collab_files_size_limits.htm&type=5
 
 
Let us know if you worked on the requirement “Upload file to record using REST API (file size should support atleast 100 MB)”
 
I'm trying to install the Einstein Discovery Writeback package so we can show recommendations from discovery on custom objects.  But installation keeps failing with this error.  I've tried recompiling with no success.  Is there some other feature or package missing that we need?

Dependent class is invalid and needs recompilation: Class analytics_ed.PredictionUtil : Type is not visible: ConnectApi.SmartDataDiscoveryPredictionIntegration: Dependent class is invalid and needs recompilation: Class analytics_ed.PredictionUtil : Type is not visible: ConnectApi.SmartDataDiscovery
Hi there, I am trying to emulate the "convert lead" action on a custom object of mine which I've made a path for (see below)User-added image

When I click on the final stage in my Path, I would like it to generate a pop-up that will then let me create new records in related objects.  Is this possible?  Here is a picture of what im talking about.

User-added image

If anyone could should me how to do this I would really appreciate it!
How can we write test class for  JWTBearerTokenExchange Class?

Main class is avilble here
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_Auth_JWTBearerTokenExchange.htm
Hi,

I am trying to configure SSO between Salesforce and Ringcentral. When I login to Ringcentral using the SSO option, it redirects me to the Salesforce error screen. On checking the SAML trace, I can see below error:

GET https://domain-name.my.salesforce.com/_nc_external/identity/saml/SamlError?idpError=1605 HTTP/1.1

Any pointers on how to resolve this?

 
I have 5 mobile fields in lead object
To avoid the lead duplicate I have to check all the 5 fields with each other

This my code is trying to check the duplicates. Is the correct way to check the duplicates?

Trigger leadduplicatecheck on lead(before insert,Before Update)
{

List<Lead> llist=new list<lead>();

Set<string> setMobilePhone =new set<String>();
Set<string> setWhatsapp =new set<String>();
Set<string> setMobile =new set<String>();
Set<string> setPhone     =new set<String>();
Set<string> setPhoneAdd =new set<String>();

for(Lead l:Trigger.new)
{
setMobilePhone.add(l.MobilePhone);
setWhatsapp.add.(l.Whatsapp_Mobile__c);
setMobile.add.(l.Mobile_Additional__c);
setPhone.add.(l.Phone);
setPhoneAdd.add.(l.Phone_Additional__c);

}

llist=[select ID from Lead where (MobilePhone =:setMobilePhone or MobilePhone=:setWhatsapp
MobilePhone =:setMobile or
MobilePhone =:setPhone or
MobilePhone =:setPhoneAdd  ) OR

(Phone =:setMobilePhone or
 Phone=:setWhatsapp or
Phone =:setPhone or
Phone =:setMobile or
Phone =:setPhoneAdd ) OR


(Mobile_Additional__c =:setMobilePhone or
 Mobile_Additional__c=:setWhatsapp or
Mobile_Additional__c =:setPhone or
Mobile_Additional__c =:setMobile or
Mobile_Additional__c =:setPhoneAdd ) OR

(Whatsapp_Mobile__c =:setMobilePhone or
 Whatsapp_Mobile__c=:setWhatsapp or
Whatsapp_Mobile__c =:setPhone or
Whatsapp_Mobile__c =:setMobile or
Whatsapp_Mobile__c =:setPhoneAdd ) OR

(Phone_Additional__c =:setMobilePhone or
 Phone_Additional__c=:setWhatsapp or
Phone_Additional__c =:setPhone or
Phone_Additional__c =:setMobile or
Phone_Additional__c =:setPhoneAdd )];



For(Lead l : Trigger.New)
{
if(Trigger.isupdate &&llist.size()>0)
{
l.adderror('Already Lead Exist with this Mobile Nuber, Duplicate');

}

if(Trigger.insert  && llist.size()>0)
{
l.adderror('Already Lead Exist with this Mobile Nuber');

}
}   
}


 
Convert a Lead to an Opportunity using triger
Hi guys given two fields on the lead object:
FieldA__c
FieldB__c
 
I need to write a trigger to convert from Lead to opportunity every time a user fill out those two fields. Can anyone help me with the trigger?
 
Thanks in advance!
Hey everyone,

I currently set up an integration with VSTS and I have been having issues passing basic HTML to a Salesforce Rich Text field and I was hoping to be pushed in the right direction.

According to this document I believe basic tags like <b>, <u>, and <i> should be able to be passed in but I cannot get it to work for the life of me. Is there anything that should be done?

This is the String value that I am attempting to pass into my Rich Text Field:
'This is a test. <b>BOLD </b><i>Italicized</i><u>Underlined</u> This was a test.'



 
Hey Folks,
I have a button in Community & I need some custom button action to be performed(not standard action).
Any help is appreciated.
For reference- https://paddycomm-developer-edition.ap5.force.com/forums/s/
more details- when a user click the Download button some custom action should be performed.currently new account is created (which I don't want).
Kindly help me on this.
Hi,

I need to design approval process we need to send approval for 5 users, 
If 1st user accepts then it need to more 2nd approval then 3rd then 4th then 5th
if any one reject that need to move back 
ex: if 3th rejects need to go to 2nd to approval.

How can we acheive these ?
Hello,

I am using Salesforce Streaming API with PushTopic for getting notifications when some Account record is updated. I am using the Service console and I am refreshing the page when I get notifications when some record was updated from the Mini Page Layout in the console. For this purpose, I have overridden the standard view detail page for Accounts. For all this, I am using PushTopic from Streaming API and CometD with jQuery on the client side. 

I want to ask, is there any possibility to hit some limits using the Streaming API with PushTopic, and what are they?     
 
Hey, 

I'm trying to create a formula for the default value based on the amount of an opportunity.

Ive created a Custom Field called 'Mark-Up' on the opportunity page which needs a default value formula of:
'Amount (of the Opportunity)' / 110 * 10

Im using the standard 'Amount' field to achieve this

However this doesnt work at all, 

Any ideas?
We have multiple opportunities for customers, some of which are stand alone, and some which are part of a larger solution. I need to be able to track these solutions and be able to create new ones when needed from the opportunity. Ideally when a new opportunity is created and the customer selected, a picklist of all current Solutions would appear, but the user could also enter a new solution when needed.

Example

Opportunity  Solution
1                   New Site Setup
2                   New Site Setup
3                   - None - 
4                  New Call Centre


1 & 2 relate to a solution that already exists for the account. 3 does not link to any solution. 4 is a new SOlution that needs adding to the list for the account in question

Does anyone have any idea on how I can go about creating this?
Hello,

Here is a phrase (highlighed in red below) I do not understand in this Trailhead: Buld Apex Triggers.

User-added image
I totally do understand the benefits of bulkifying SOQLs and DMLs in apex triggers and/or apex Classes.

But, I think this phrase (forgive my poor English) is refeering to statements where you combine a for each loop and an SOQL ? Like below, in lines 5 and 6:
trigger SoqlTriggerBulk on Account(after update) {  
    // Perform SOQL query once.    
    // Get the related opportunities for the accounts in this trigger,
    // and iterate over those records.
    for(Opportunity opp : [SELECT Id,Name,CloseDate FROM Opportunity
        WHERE AccountId IN :Trigger.New]) {
  
        // Do some other processing
    }
}
But, I do not quite understand the relationship between the fact that you can "unify" in one statement the for each and the SQL AND a potential "Benefit" to do this in terms of performance or efficiency.

What do you mean by "benefit of SOQL for loop"?

Thank you  very much.

 
Hi, I have the following issue,

I need to use jquery ui autocomplete in a textarea in lightning. In a visualforce page works perfectly, but in a lightning component it does not work, the list of suggestions does not appear.

In the browser console there is no error, and if through a console.log I print what has the source attribute shows me the whole list, ie the list loads well but there is a problem that does not want to show suggestions to the typing time.

jquery ui 1.12.1
jquery 2.2.4

also try with jquery 1.11.4 and it does not work either.

Any ideas?
Step 7 - Synchronize Salesforce project data with Square Peg's external billing system

I'm getting an error message when triggering the SOAP call from the UI via record update:

System.CalloutException: IO Exception: External server did not return any content

When I import the WSDL into SOAP UI and send the same package body, I receive this message:
HTTP/1.1 500 
Server: Cowboy
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Mon, 10 Jul 2017 17:58:08 GMT
Via: 1.1 vegur
Proxy-Connection: Keep-Alive
Connection: Keep-Alive

{"timestamp":1499709488068,"status":500,"error":"Internal Server Error","exception":"java.lang.OutOfMemoryError","message":"unable to create new native thread","path":"/ws"}

Does this mean that the herokuapp needs to be restarted or something? I've found a couple of posts with sample code for this challenge and with a few small differences, mine matches from what I can tell. Here's the code I'm using:

ProjectTrigger
trigger ProjectTrigger on Project__c (after update) {
    //Call the Billing Service callout logic here

    if (trigger.isAfter && trigger.isUpdate) {
        BillingCalloutService.callBillingService(Trigger.new, Trigger.newMap, Trigger.old, Trigger.oldMap);
    }

}

BillingCalloutService
public class BillingCalloutService {
    //Implement business and callout logic methods here
    public static void callBillingService(List<Project__c> newList, Map<Id, Project__c> newMap,
            List<Project__c> oldList, Map<Id, Project__c> oldMap) {

        if(!newList.isEmpty()) {
            Project__c project = newList[0];
            if (project.Status__c == 'Billable' && oldMap.get(project.Id).Status__c != 'Billable') {
                // Get Service Credentials from custom settings
                ServiceCredentials__c credentials = ServiceCredentials__c.getInstance('BillingServiceCredential');
                billProject(project.ProjectRef__c, project.Billable_Amount__c, credentials.Username__c, credentials.Password__c);
            }
        }
    }

    @Future(callout=true)
    private static void billProject(String projectRef, Decimal billAmount, String username, String password) {

        BillingServiceProxy.project project = new BillingServiceProxy.project();
        project.projectRef = projectRef;
        project.billAmount = billAmount;
        project.username = username;
        project.password = password;

        BillingServiceProxy.InvoicesPortSoap11 invoiceCall = new BillingServiceProxy.InvoicesPortSoap11();
        // Make the callout and update the Status if callout is successful
        String response = invoiceCall.billProject(project);

        List<Project__c> projects = new List<Project__c>();
        if(response != null && response.equalsIgnoreCase('OK')) {

            projects = [
                    Select Id, Status__c
                    From Project__c
                    Where ProjectRef__c = :projectRef
            ];
            if(!projects.isEmpty()) {
                projects[0].Status__c = 'Billed';
                update projects;
            }
        }

    }
}

BillingServiceProxy
//Generated by wsdl2apex

public class BillingServiceProxy {
    public class billProjectRequest_element {
        public BillingServiceProxy.project project;
        private String[] project_type_info = new String[]{'project','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://salesforce.com/th/invoice-web-service','true','false'};
        private String[] field_order_type_info = new String[]{'project'};
    }
    public class project {
        public String username;
        public String password;
        public String projectRef;
        public Double billAmount;
        private String[] username_type_info = new String[]{'username','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
        private String[] password_type_info = new String[]{'password','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
        private String[] projectRef_type_info = new String[]{'projectRef','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
        private String[] billAmount_type_info = new String[]{'billAmount','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://salesforce.com/th/invoice-web-service','true','false'};
        private String[] field_order_type_info = new String[]{'username','password','projectRef','billAmount'};
    }
    public class billProjectResponse_element {
        public String status;
        private String[] status_type_info = new String[]{'status','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://salesforce.com/th/invoice-web-service','true','false'};
        private String[] field_order_type_info = new String[]{'status'};
    }
    public class InvoicesPortSoap11 {
        public String endpoint_x = 'http://sb-integration-bs.herokuapp.com:80/ws';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'http://salesforce.com/th/invoice-web-service', 'BillingServiceProxy'};
        public String billProject(BillingServiceProxy.project project) {
            BillingServiceProxy.billProjectRequest_element request_x = new BillingServiceProxy.billProjectRequest_element();
            request_x.project = project;
            BillingServiceProxy.billProjectResponse_element response_x;
            Map<String, BillingServiceProxy.billProjectResponse_element> response_map_x = new Map<String, BillingServiceProxy.billProjectResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://salesforce.com/th/invoice-web-service',
              'billProjectRequest',
              'http://salesforce.com/th/invoice-web-service',
              'billProjectResponse',
              'BillingServiceProxy.billProjectResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.status;
        }
    }
}

Any ideas what I'm doing wrong here? Any assistance would be most appreciated!

Thanks!



 
In the Sales Wave App module, specifically Creating Sales Wave Using the Wizard, there is a step where you use the Trailhead Data Manager to download the dataflow. Whenever I click on Download Trailhead Dataflow I receive the message "No SalesWave App found" and therefore I am not able to select my app. The app was created yesterday but still no luck. Any suggestions?

Hi 

 

we have a validation rule on Lead object ,we need to make  this validation rule as inactive like do not fire in the trigger which is on task object .the trigger is copying some field values from task  to the lead object.

 

Thanka in advance

  • April 10, 2013
  • Like
  • 2