• Anil Savaliya
  • NEWBIE
  • 248 Points
  • Member since 2013
  • Salesforce Developer
  • WellsFargo & Comapany.

  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 10
    Questions
  • 70
    Replies
Hi,
 
    I am not able to see future method logs in production server where as I can see thos elogs on my sandbox account ?
    Can anyone please help me, How can I enable future method logs in production server ?
    Note : However I can see application logs in my production salesforce.   

Thank,
Abhishek
Here is the code that I am using sorry if it is not clean or hard to read new to development and haven't learned how to clean up the mess. 


trigger AssignTerritoryType on Account (before insert, before update) {
For (Account a :trigger.new){
  Set<string> majorIndustries = new Set<string>{'Pharma/BioTech', 'Energy', 'Fed - Gov' ,'State - Mid','Education'};
if ( (a.NumberOfEmployees >= 10000) ||
      (a.AnnualRevenue >= 500000000) ||
   (a.Fortune_500__c = true) ||
   ( (a.Fortune_500_1000__c = True) && (a.NumberOfEmployees >=10000) && (a.AnnualRevenue >= 500000000) ) || //note that even if a.Fortune_500_1000__c = False it'll fall if a.NumberOfEmplyees >=10000 is true or A.AnnualRevenue>=500000000 since it will meet a previous condidtion
   majorIndustries.contains(a.Industry) = 'Pharma/BioTech')
   {
  a.Major__c=true;
    }
if ( ((a.NumberOfEmployees < 10000) && (a.NumberOfEmployees >=4000)) ||
     ((a.AnnualRevenue > 500000000) && (a.AnnualRevenue <=250000000)) ||
     ((a.Fortune_501_1000__c = true) &&(a.NumberOfEmployees > 10000) && (a.AnnualRevenue > 500000000))||
     (majorIndustries.contains(a.Industry) = 'State - mid')||
     ((a.NumberOfEmployees >=8000) && (majorIndustries.contains(a.Industry) = 'Education')
     )
   )
   {  
  a.Mid__c=true;
}
if   ((a.NumberOfEmployees < 4000) && (a.NumberOfEmployees >=1500)
     )
   {
  a.Inside__c=true;
   }
If   ((a.NumberOfEmployees < 4000)
  )
   {
  a.Inside_small__c=true;
   }
}
}

Hi there,

 

I have a querry in my apex trigger that looks like this:

 

      List<DatedConversionRate> ExchRateCache = [SELECT ISOCode, ConversionRate,  StartDate, NextStartDate FROM DatedConversionRate where ISOCode in :CurrCodes ];

 

This works fine, but it pulls the currency exchange rate of all time, and I only want the exchange rate on the 1st day of the month. I then changed it as below.

 

      List<DatedConversionRate> ExchRateCache = [SELECT ISOCode, ConversionRate,  StartDate, NextStartDate FROM DatedConversionRate where ISOCode in :CurrCodes AND ExchRateCache.StartDate.Day()='1'];

 

But I got an error saying "unexpected token: ')' at line 70 column 192"

 

Can some one be so kind and give me some instruction? Very much appreciate!

Alice

Greetings,

 

I have a custom controller and visualforce page.  Long story short, one of the fields I am querying is a formula field that I would like to display on the visualforce page.  No values are displayed.  Any thoughts on how I can get the formula field to populate the value?

 

Here is the method from my controller:

"team_number__c" is the formula field that will not populate on the visualforce page.

 

public list<MyCarrier> getCarriers(){
string sortFullExp = sortfield + ' ' + sortDirection;
carriers.clear();
for(carrier__c c : database.query('select team_number__c, insurance_requested__c, load_date_time__c, date_submitted__c, lastmodifiedby.alias, id, team__c, references__c, requester__c, fraud_websites__c, Insurance_received__c, conditional_letter__c, contract__c, MC_Number__c, compliance_action__c, attachment__c, name from carrier__c where team__c != NULL order by ' + sortFullExp ))
{
carriers.add(new myCarrier(c));
}
return carriers;
}

 

 

 

This is the formula that populates "team_number__c":::

if(Team__c = "t9chop1", "Team 9", if(Team__c = "t1chop2", "Team 1",""))

Hi,

 

We have a custom button on a custom object. We click on this button and the javascript performs the actions based on a field in this custom object. The field is a checkbox field and it has default value as unchecked. Like this - 

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

If field A = 0 (unchecked)

     perform AAA

else

     perform BBB

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

But we want to update the field value (checkbox should become checked) when if statement encounters the value = 0

 

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

If field A = 0 (unchecked)

     update A = 1

     perform AAA

else

     perform BBB

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

How can we achieve this?

Thanks in advance!

 

Best regards

  • November 20, 2013
  • Like
  • 0

hi friends

pls help me with this simple scenario

I have 200 users ,in that i want to restrict "user 1" to view ,edit, or delete oppurtunity standard object only...how do i do this ..?

 

thanks

Hi Guys,

I am implementing API with our system,After Rest API  call i getting JSON response,Please see in example for json response,i need to convert JSON string in CSV file and need export csv, How can i implement ? Any Idea ? sample code ?
Response : 
[
    {
        "Revenue": "$1,000,000",
        "Employees": "12345",
        "MarketCap": "$1,000,000",
        "Website": "www.yahoo.com",
        "WebsiteURL": "http://www.yahoo.com",
        "Industry": "Information Technology",
        "LongDescription": "Long text",
        "Description": "Discripting here",
        "NodeID": "Org|345222",
        "DisplayName": "Yahoo News"
    },
    {
        "Revenue": "$2,000,000",
        "Employees": "345435",
        "MarketCap": "$1,02300,000",
        "Website": "www.google.com",
        "WebsiteURL": "http://www.google.com",
        "Industry": "Information Technology",
        "LongDescription": "Long text",
        "Description": "Discripting here",
        "NodeID": "Org|5323232",
        "DisplayName": "Google Search"
    },
    {
        "Revenue": "$5000,000,000",
        "Employees": "500000",
        "MarketCap": "$2,000,0000000",
        "Website": "www.apple.com",
        "WebsiteURL": "http://www.apple.com",
        "Industry": "Telecommunication",
        "LongDescription": "Long text",
        "Description": "Discripting here",
        "NodeID": "Org|534534",
        "DisplayName": "Apple News"
    }
]
Hey,

I am trying to creat visualforce page,and it's render as a PDF,But CSS is working only when i write inline style, But It's not working when i write different in class,

For expriment You can take w3 school sample code : 
http://www.w3schools.com/html/tryit.asp?filename=tryhtml_layout_divs  and page render as PDF

Any comment ? Any Idea ? Any suggestion ?
Hey,

I have contact Followed Object ,and It has master detail retailionship with contact and look up with user.

When I am deleteing contact ,it's delete contact follow by.it's natural and expected.But when I see debug log  there is DML opetion happening for Delete Contact ,But I can't see DML opertion for Delete Contact Follow,But it's deleting contact follow by.Becuase of absent of DML opertion  in contact follow,My trigger is not firring for contact follow by ?

This behaviour is natural or weired ?
Hello

I getting response in JSON body like
String JS = '[{"User": "12345","Statuses": [{ "EntityId": 123, "Status": "Success" },{ "EntityId": 456, "Status": "Fail" }]},{"User": "67891","Statuses": [{ "EntityId": 345, "Status": "InvalidEntity" },{ "EntityId": 456, "Status": "Success" },{ "EntityId": 456, "Status": "Fail" }]}]';

and I have custom object exception_c and it's two custom field ExceptionUser__c and ExceptionEntityId__c

How can i write logic for exception record insert in case only status fail ?
If status fail insert exception record associate user and entityId assosiate with failer responce?

String JS = '[{EntityID:3140001, User: "ABC@test.com"},{EntityID:4902138, User: "ABC@test.com"},{EntityID:43962599, User: "ABC@test.com"},{EntityID:46326732, User: "ABC@test.com"},{EntityID:50678752, User: "ABC@test.com"},{EntityID:3471919, User: "ABC@test.com"},{EntityID:3529201, User: "ABC@test.com"},{EntityID:3145503, User: "ABC@test.com"},{EntityID:478345, User: "ABC@test.com"},{EntityID:3599697, User: "ABC@test.com"},{EntityID:459246, User: "ABC@test.com"},{EntityID:49732437, User: "ABC@test.com"},{EntityID:3858674, User: "ABC@test.com"},{EntityID:459246, User: "ABC@test.com"},{EntityID:478345, User: "ABC@test.com"},{EntityID:3227994, User: "ABC@test.com"},{EntityID:3227994, User: "ABC@test.com"},{EntityID:124412, User: "ABC@test.com"},{EntityID:3140001, User: "xyz@test.com"},{EntityID:4902138, User: "xyz@test.com"},{EntityID:43962599, User: "xyz@test.com"},{EntityID:46326732, User: "xyz@test.com"},{EntityID:50678752, User: "xyz@test.com"},{EntityID:3471919, User: "xyz@test.com"},{EntityID:3529201, User: "xyz@test.com"},{EntityID:3145503, User: "xyz@test.com"},{EntityID:478345, User: "xyz@test.com"},{EntityID:3599697, User: "xyz@test.com"},{EntityID:459246, User: "xyz@test.com"},{EntityID:49732437, User: "xyz@test.com"},{EntityID:3858674, User: "xyz@test.com"},{EntityID:459246, User: "xyz@test.com"},{EntityID:478345, User: "xyz@test.com"},{EntityID:3227994, User: "xyz@test.com"},{EntityID:3227994, User: "xyz@test.com"},{EntityID:124412, User: "xyz@test.com"}][{EntityID:3140001, User: "ABC@test.com"},{EntityID:4902138, User: "ABC@test.com"},{EntityID:43962599, User: "ABC@test.com"},{EntityID:46326732, User: "ABC@test.com"},{EntityID:50678752, User: "ABC@test.com"},{EntityID:3471919, User: "ABC@test.com"},{EntityID:3529201, User: "ABC@test.com"},{EntityID:3145503, User: "ABC@test.com"},{EntityID:478345, User: "ABC@test.com"},{EntityID:3599697, User: "ABC@test.com"},{EntityID:459246, User: "ABC@test.com"},{EntityID:49732437, User: "ABC@test.com"},{EntityID:3858674, User: "ABC@test.com"},{EntityID:459246, User: "ABC@test.com"},{EntityID:478345, User: "ABC@test.com"},{EntityID:3227994, User: "ABC@test.com"},{EntityID:3227994, User: "ABC@test.com"},{EntityID:124412, User: "ABC@test.com"},{EntityID:3140001, User: "xyz@test.com"},{EntityID:4902138, User: "xyz@test.com"},{EntityID:43962599, User: "xyz@test.com"},{EntityID:46326732, User: "xyz@test.com"},{EntityID:50678752, User: "xyz@test.com"},{EntityID:3471919, User: "xyz@test.com"},{EntityID:3529201, User: "xyz@test.com"},{EntityID:3145503, User: "xyz@test.com"},{EntityID:478345, User: "xyz@test.com"},{EntityID:3599697, User: "xyz@test.com"},{EntityID:459246, User: "xyz@test.com"},{EntityID:49732437, User: "xyz@test.com"},{EntityID:3858674, User: "xyz@test.com"},{EntityID:459246, User: "xyz@test.com"},{EntityID:478345, User: "xyz@test.com"},{EntityID:3227994, User: "xyz@test.com"},{EntityID:3227994, User: "xyz@test.com"},{EntityID:124412, User: "xyz@test.com"}]';


I need get value between each {.......},How can i get ? I try use

string subject = JS;
Pattern p = Pattern.compile('\\{(.+?)\\}');

Matcher m = p.matcher(subject);
,But it's not work

How could get value like

Index 1 = EntityID:3140001, User: "ABC@test.com"
Index 2 = EntityID:4902138, User: "ABC@test.com"
----------------------------------------------------------
--------------------------------------------------------
Index  40 (Last any number) = EntityID:124412, User: xyz@test.com (mailto:xyz@test.com)

I have requirment to make callout from trigger ,Because limitation ,We can't  write call out in trigger, so I writed future method for call out,But I am facing now callout limit issue,Do you any body have code,I can make batch for call out . here is my code.

Calling from Trigger Below method:
/*********************Trigger**************************/
trigger contactFollow_checkEntitySubscription on Contacts_Followed_By__c(after insert, after delete, after update) {
if(Trigger.isInsert || Trigger.isUpdate){
        for(Contacts_Followed_By__c  contactFollow: Trigger.new){
  
            contactFollowIdSet.add(contactFollow.Id);
           
        }
--------------------------
------
AddAndDeleteRelSciController.RecordToGetAddRelSci(contactFollowIdSet);
}

/***********Class *********/

Public Class AddAndDeleteRelSciController{
Public static String JSONstring;
Public static Map<String, List<String>> userContactFollowMap = new Map<String, List<String>>();

Public Static  void RecordToGetAddRelSci(Set<Id> contactFollowersIdSet){
    //query all the user fields from the contactFollowersIdSet
    List<Contacts_Followed_By__c> conFollowsList = [Select Id, User__c, User__r.Name, User__r.FederationIdentifier, Contact__c, Contact__r.rels__EntityId__c
                                                   FROM Contacts_Followed_By__c  WHERE Id IN :contactFollowersIdSet];
                           
    for(Contacts_Followed_By__c conFollower : conFollowsList)
    {
        List<String> entityIdLIst = new List<String>();
        if(userContactFollowMap.containsKey(conFollower.User__R.FederationIdentifier))
        {
            entityIdLIst = userContactFollowMap.get(conFollower.User__R.FederationIdentifier);
        }
        entityIdLIst.add(conFollower.Contact__r.rels__EntityId__c);
        userContactFollowMap.put(conFollower.User__R.FederationIdentifier, entityIdLIst);
        System.debug('*************** ' +userContactFollowMap);
        AddRelSci(conFollower.User__R.FederationIdentifier, entityIdLIst);
       
    }
}

@Future (callout=True)
Public Static  void AddRelSci(String UsrName,List<String> Cntc){
    Try{ System.debug('*****Final Test****'+UsrName+'---'+ Cntc) ;
        If(UsrName != Null & !Cntc.isEmpty() ){
           
            integer i;
            String endpointUrl =  Relationship_API_Setting__c.getValues('RelSciAPI').Add_Method_EndPointUrl__c;
            String username = Relationship_API_Setting__c.getValues('RelSciAPI').UserName__c;
            String password = Relationship_API_Setting__c.getValues('RelSciAPI').Password__c;
            HttpRequest req = new HttpRequest();
            req.setMethod('POST');
            req.setHeader('Username', Username);
            req.setHeader('password', password);
            req.setHeader('UserIdentifier',UsrName);
            req.setHeader('Content-Type', 'application/json');
            req.setHeader('Accept','application/json');
            req.setEndpoint(endpointUrl);
            String JS = '[{EntityId: ';
            integer S ;
            for(S=0;Cntc.size()>S;S++){
                JS = JS+''+Cntc[S]+'},{EntityId: ';
            }
            JSONstring = JS.SubString(0,JS.length()-12)+']';
            System.debug('*******Add JSON String*******'+JSONstring);
            req.setBody(JS);
            If(Relationship_API_Setting__c.getValues('RelSciAPI').RelSci_API_is_Available__c){
                Http http = new Http();
                HttpResponse resp = http.send(req);
                system.debug('*******Add Status Response*******'+resp.getStatus());
                system.debug('*******Add Body Response*******'+resp.getBody());
                If(resp.getStatus() != 'OK'){
                    Exception__c ex= new Exception__c();  
                    ex.Erro_occur_for_user__c = UsrName ;
                    ex.Error_Occured_for_EntityID__c = JSONstring;
                    ex.Error_Code__c = string.valueof(resp.getStatusCode());
                    ex.Error_Status__c = resp.getStatus();
                    ex.Error_Message__c = resp.getBody();
                    ex.Error_Module__c = 'Relationship Science';
                    ex.Error_Generated_From_Method__c = 'ADD';
                    insert ex;
                }
            }
            Else{
                Exception__c ex= new Exception__c();  
                ex.Erro_occur_for_user__c = UsrName ;
                ex.Error_Occured_for_EntityID__c = JSONstring;
                ex.Error_Code__c = '001';
                ex.Error_Status__c = 'RelSci API is Down';
                ex.Error_Message__c = 'RelSci API is Down';
                ex.Error_Module__c = 'Relationship Science';
                ex.Error_Generated_From_Method__c = 'ADD';
                insert ex;
            }
        }
    }
    Catch (Exception E)
    {
        Exception__c ex= new Exception__c();
        ex.Erro_occur_for_user__c = UsrName ;
        ex.Error_Occured_for_EntityID__c = JSONstring;
        ex.Error_Code__c = '000';
        ex.Error_Status__c = 'Unexpected Exception';
        ex.Error_Message__c = E.getMessage();
        ex.Error_Module__c = 'Relationship Science';
        ex.Error_Generated_From_Method__c = 'ADD';
        insert ex;
    }
}

}

How can method from trigger in form batch,So i can't hit limit 10 call out ?
Hi,
I have custom object Target.we are created custom visualforce page and assigned to Target Tab.We used custom visualfoce for targert because we have lot of  validation during record save and page layout implemention according to product selected.

Example : Assiged Visaulforce CreateTarget to target tab (/apex/CreateTarget).Now business want to create clone button on created visualforcepage (CreateTarget).Is there any API for Clone or Idea?

Please help on create custom clone button on visualforce page?
Hi,
I have custom object Target.we are created custom visualforce page and assigned to Target Tab.We used custom visualfoce for targert because we have lot of  validation during record save and page layout implemention according to product selected.

Example : Assiged Visaulforce CreateTarget to target tab (/apex/CreateTarget).Now business want to create clone button on created visualforcepage (CreateTarget).Is there any API for Clone or Idea? 

Please help on create custom clone button on visualforce page?

Hi,

 

I created section in account calls 'RelSci',and assiged visualforce page on that section,Rendering section only who has permission to use 'RelSci' function.When Visualforce page make rendered = 'False',In account view,RelSci visualforce page disapper but leaving white space,Any idea to remove white space?

Hello,

We are looking saleforce Architech in out team.It is full time position in charllote,NC.No corp - Corp  or third parties Please .send resume to beanil.savalia@gmail.com .

As per release winter 16 release notes: http://releasenotes.docs.salesforce.com/en-us/winter16/release-notes/salesforce_release_notes.htm
 

REQUIRESCRIPT no longer executes JavaScript on Page Load.

We use the REQUIRESCRIPT function in several custom buttons on our lead page.  When the Winter 16 features were released into our sandbox, our buttons started returning an error Reference $ Undefined.

I reached out to salesforce support, and they told me to use the code in the following article which removed the REQUIRESCRIPT function and instead, creates a custom java function.

https://help.salesforce.com/apex/HTViewSolution?urlname=Receiving-error-sforce-apex-is-null-or-not-an-object-1327108329858&language=en_US

I've been messing with the code above to fit it into my button.  I'm stepping through the code through alerts, it stepped all the way through but at the end I get an Object error.  Any help would be appreciated.

function loadScript(url) 

    var request; 
    if (window.XMLHttpRequest) 
    { 
        request = new XMLHttpRequest(); 
    }     
    else if (window.ActiveXObject) 
    { 
        request = new ActiveXObject("Msxml2.XMLHTTP"); 
        if (!request) 
        { 
            request = new ActiveXObject("Microsoft.XMLHTTP"); 
        } 
    
    } 


    var se = document.createElement('script'); 
    se.type = "text/javascript"; 
    //alert("before Request undefined\n");
    request.open("GET", url, false); 
    request.send(null); 
    se.text = request.responseText; 
    document.getElementsByTagName('head')[0].appendChild(se); 
    //alert("end of loadScript\n");


loadScript("/soap/ajax/30.0/connection.js"); 
loadScript("/soap/ajax/30.0/apex.js"); 
loadScript("/resource/jQuery/jquery-1.8.2.min.js"); 
loadScript("/resource/jQuery/ui/jquery-ui-1.9.1.custom.min.js");
loadScript("/resource/jQuery/postmessage/jquery.ba-postmessage.js");
loadScript("/resource/jQuery/bbq/jquery.ba-bbq.min.js");
loadScript("/resource/buttonjs");

try 

    var j$ = jQuery.noConflict(); 
    var newurl= sforce.apex.execute("RegisterMerchant", "getPricingArticleID",{leadID : "{!Lead.Id}"}); 
    newurl1 = String(newurl); 
    alert('Lead ArticleID '+newurl1); 
    if(newurl1.indexOf('error')>-1 ) 

    alert(newurl); 
    document.location.reload(true); 

else 

    alert('Start of Else Statement')
    var strQuery="Select l.of_Pin_Pads__c,l.Id, l.Article_ID__c, l.Processing_Origin__c, l.Company, l.Strategic__c, l.Gift_Only__c, l.Dealer__r.Name, l.Developer__c, l.DLR_Sales__c, l.Name, l.OwnerId from Lead l where Id= '" +'{!Lead.Id}'+"'"; 
    var accFields = sforce.connection.query(strQuery); 
    var records = accFields.getArray("records"); 

    var owner = records[0].OwnerId; 
    var ContactName = records[0].Name; 

    var leadId = records[0].ID; 
    var Dealer = records[0].Dealer__r.Name; 
    var devID = records[0].Developer__c; 
    var Developer = null; 
    var DealerSalesperson = null; 
    if (devID!=null) 
    alert('Developer Record')
    

    var strQuery3 = "SELECT Name from Account where ID='" +devID+"'"; 
    var devField = sforce.connection.query(strQuery3); 
    var devRecord = devField.getArray("records"); 
    Developer = devRecord[0].Name; 
    


var ds = records[0].DLR_Sales__c; 
//if (ds!= null) 
    alert('DLR sales Record1')
//{ 
var strQuery6 = "Select Name from Contact where id = '" +ds+"'"; 
var dlrSalesField = sforce.connection.query(strQuery6); 
var dlrSalesRecord = dlrSalesField.getArray("records"); 
DealerSalesperson = dlrSalesRecord[0].Name; 
//}
alert('Dlr sales Record2') 

var NumberOfPinpads = 0; 
//if(records[0].of_Pin_Pads__c!=null) 
//{ 
NumberOfPinpads = parseInt(records[0].of_Pin_Pads__c); 
//}
alert('Pin Pads') 
var ArticleId = records[0].Article_ID__c; 
var ProcessingOrigin = records[0].Processing_Origin__c; 
var CompanyName = records[0].Company; 
var StrategicAccount= records[0].Strategic__c; 
var GiftOnly = records[0].Gift_Only__c; 
alert('Other stuff') 


// if diff is null, continue, if user clicked cancel, allow them to chg processing origin 
console.log('leadId '+leadId+'--'+Dealer+'--'+Developer+'--'+ArticleId+'--'+DealerSalesperson); 
// next section stolen from Josh, thanks for doing my typing buddy! 
var $articleId = $('<input>', { name: 'ArticleId', type: 'hidden', value: ArticleId }); 
var $processingOrigin = $('<input>', { name: 'ProcessingOrigin', type: 'hidden', value: ProcessingOrigin }); 
var $companyName = $('<input>', { name: 'CompanyName', type: 'hidden', value: CompanyName }); 
var $strategicAccount = $('<input>', { name: 'StrategicAccount', type: 'hidden', value: StrategicAccount }); 
var $giftOnly = $('<input>', { name: 'GiftOnly', type: 'hidden', value: GiftOnly }); 
var $contactName = $('<input>', { name: 'ContactName', type: 'hidden', value: ContactName }); 
var $dealer = $('<input>', { name: 'Dealer', type: 'hidden', value: Dealer }); 
var $developer = $('<input>', { name: 'Developer', type: 'hidden', value: Developer }); 
var $dealerSalesperson = $('<input>', { name: 'DealerSalesperson', type: 'hidden', value: DealerSalesperson }); 
var $numberOfPinpads = $('<input>', { name: 'NumberOfPinpads', type: 'hidden', value: NumberOfPinpads }); 

//alert($articleId.html()); 
var $form = $('<form>', { 
'action': '{!$Label.pricingUI}Invoke', 
'method': 'post', 
'target':'_blank' 
}); 

$form.append($articleId); 
$form.append($processingOrigin); 
$form.append($companyName); 
$form.append($strategicAccount); 
$form.append($giftOnly); 
$form.append($contactName); 
$form.append($dealer); 
$form.append($developer); 
$form.append($dealerSalesperson); 
$form.append($numberOfPinpads); 

$(document.body).append($form); 

$form.submit(); 
// alert('done by me'); 


catch(er) 

alert(er); 
}
 

Hi,
i have a requirement where, some statndards components needed to be hidden. With winter 16 release this is not working as expected. 
Does anyone have a workaround for this??
I have this trigger that i created but i am unable to figure out how to get the query out of the for loop, my trigger will run but i know it will hit some governer limits. 

trigger AcceptJobAndCreateEmployee on Candidate_Application__c (after update) {
    
    //This will be the list to add the new candidate
    List<Account> accounts = new List<Account>();

    //Query for the Account Record Types
    List<RecordType> rtypes = [Select name, id FROM RecordType WHERE sObjectType = 'Account' AND IsPersonType = True];
   
    Map<String,String> accountRecordTypes = new Map<String,String>();
        for(RecordType rt: rtypes){
            accountRecordTypes.put(rt.Name,rt.id);
        }
        
    

    for(Candidate_Application__c thisApplication: Trigger.new)
    {
        Candidate_Application__c oldApp = Trigger.oldMap.get(thisApplication.id);
        Boolean AppFalse = oldapp.Job_Accepted__c;
        Boolean AppTrue = thisApplication.Job_Accepted__c;
        
       List <Candidate__c> newCandidates = [Select id, name FROM Candidate__C WHERE id =: thisApplication.Candidate__c]; 
        
        if(!AppFalse && AppTrue)
        {            
            if(newCandidates.size() > 0){
                Account converted = new Account();
            
            
                converted.RecordTypeid = accountRecordTypes.get('Person Account');
                converted.LastName = newCandidates.get(0).Name;
                converted.Phone = newCandidates.get(0).Phone__c;
              
                
                accounts.add(converted);
                
            }
            

        }

    }

    insert accounts;
}
Hi

We have an ecommerce site in php that builds some text string which is emailed to a custom email address in salesforce crm. We need to make some changes in salesforce to exsiting customisation, so are looking for a certified salesforce expert. Please see an example of the information we are sending


title:Mrs<eol>
first_name:Example<eol>
last_name:Example<eol>
homeno:0Example<eol>
mobile:<eol>
email:Example@me.com<eol>
dob:1970-08-16<eol>
address1:My Address <eol>
address2:Example<eol>
town:Bury<eol>
county:Greater Manchester<eol>
post_code:EX1 4PL<eol>
reg_no:Example<eol>
make:Hyundai<eol>
model:i30<eol>
specification:Premium<eol>
style:Hatchback<eol>
engine_cc:1600<eol>
fuel_type:Diesel<eol>
transmission:Manual<eol>
financed:No<eol>
vehicle_purchase_date:2014-93-19<eol>
purchase_value:16000.00<eol>
first_registered_date:2013-09-10<eol>
current_mileage:8843<eol>
gap_policy_type:Vehicle Replacement Insurance<eol>
gap_term:5 Years<eol>
gap_claim_limit:£15000<eol>
gap_price:250<eol>
tyre_policy_type:<eol>
tyre_term:<eol>
tyre_claim_limit:<eol>
tyre_price:<eol>
warranties_policy_type:<eol>
warranties_term:<eol>
warranties_claim_limit:<eol>
warranties_price:<eol>
mot_policy_type:<eol>
mot_term:<eol>
mot_claim_limit:<eol>
mot_price:<eol>
smart_policy_type:<eol>
smart_term:<eol>
smart_claim_limit:<eol>
smart_price:<eol>

I believe we are using a email service and a logic to read it.

We are looking to include a number of extra fields and also set up SF to automatically send an email template to the contact on creation of the account.

Long term, we will be working on a number of similar projects so would like to work with a Salesforce approved/credited company.

Please contact us if you would like more information and to provide a quotation.
I am looking for someone to advise on the best way to:

* Call an external URL when certain salesforce objects (household,contact,activity) are insert/update/deleted
* Ease the registration for calling into the salesforce API (such as using remote site settings when installing AppExchange packages)

and implement it.
Hello,

I'm trying to strategize how best to run this series of SOQL queries without triggering the limits. I have a csv of approximately 10,000 records. The goal is to check for each record whether there is a contact.owner.name associated with it. For instance (not complete, of course):

For(integer i:[csv file]){
SELECT Contact.Owner.Name. Contact.Custom_Field__c FROM Contact WHERE Contact.Custom_Field__c = csvFile[i]
}

How would you recommend I grab the data for all 10,000 records?

Thank you so much for your time and consideration of my inquiry.

With gratitude,
Zac
I am looking to find someone that can do some coding for me to rollup counts from Activities.  I.E
shows amount of times the activity shows as No Answer, Answering Machine etc and also updates the lead status aswell.  

Basic functions to allow me to remove some leads from list view after we have attempted them a few times.
 
We have some custom buttons being developed that we only want to be displayed if items in a picklist match a certain criteria. For example, if the product field is a product that starts with the letter A, don't show the the buttons. If the product selected starts with the letter B, show the buttons (we only have two options that products can start with so it's pretty simple).

My initial idea was to use record types, page layouts, and WFR's, but we already use record types and there is potentially alot of intergration from our software engineers who use this object that we don't want to worry about messing that up. So while we work that part out, is there anything programatically we can do to show or hide buttons based on a field on the record? Without using record types?
Hey,

I am trying to creat visualforce page,and it's render as a PDF,But CSS is working only when i write inline style, But It's not working when i write different in class,

For expriment You can take w3 school sample code : 
http://www.w3schools.com/html/tryit.asp?filename=tryhtml_layout_divs  and page render as PDF

Any comment ? Any Idea ? Any suggestion ?
Dear fellows

I've come across to an error in one of my apex classes:

Error:Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ClientInvoiceAfterUpdate: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0Tb000000E6kACEAZ; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ClientInvoiceAfterUpdate: execution of AfterUpdate caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times) Class.AP516_SetTECHAmountDue.updateTechAmountDue: line 29, column 1 Trigger.ClientInvoiceAfterUpdate: line 189, column 1: [] Class.AP511_SetTechTotalAmountDue.updateAmtDueCurrency: line 149, column 1 Trigger.ClientInvoiceAfterUpdate: line 177, column 1: []

The query is really simple and, as sugested by salesforce, I've splitted the filters of the query to see if in any of them, the result is greater than 100k records. The object where this query is running against to, has more than 100k records as well but the filter when applied separately retrieves way less than 100k records.

Your help and guidance are really appreciated

Best Regards,

Roniel Navarro
Hi,
 
    I am not able to see future method logs in production server where as I can see thos elogs on my sandbox account ?
    Can anyone please help me, How can I enable future method logs in production server ?
    Note : However I can see application logs in my production salesforce.   

Thank,
Abhishek
I would like to manually alter/code the menu bar in my customer portal because I would like to add a navbar with dropdowns (which I believe salesforce does not have out of the box).

How can I do this?
Hi I have the following in a visual force template:
&nbsp;<b>Open Date:</b> &nbsp;<apex:outputText value="{0,date,EEEE, MMMMM dd, yyyy 'at' HH:mm:ss z}"><apex:param value="{!relatedto.BMCServiceDesk__openDateTime__c}" /></apex:outputText><br/>

However this is showing the time as GMT and not BST so is one hour behind.  How would I correct this?

Thanks in advance for any input

Sonya
Hi,

We'd like to be able to query some of our Salesforce data from our front-end web app in order to get some information back for the current application user. Specifically we would like to query Salesforce based on a contact role email address in order to determine what Salesforce accoutn they are associated as well as retrieving information from related account opportunities. 

Thanks, Paul
Hello,

First time question here from a Apex Newbie.....

I have a standard object (Case) which will have a currency field, that I want to update from a rollup summary field on a custom object (Work Order) called Price__c.  The Price__c field on the Work Order Custom Object totals all work order work detail lines, and I want the Price__c field to update the currency field on the case record.  

So far I have the following code written, but I am getting an Invalid Ofreign Key error when tring to quick save.  Can anyone help me here......Thank you in advance

trigger DoRollup on SVMXC__Service_Order__c (after insert, after update, after delete, after undelete) {
    Set<Id> setCaseId=new Set<Id>();
    Map<string,decimal> CaseWithTotalWorkOrders=new Map<string,decimal>();
    for(SVMXC__Service_Order__c mst:Trigger.New){
    if(Case.Total_Billable_Work_Orders__c!=null){
     setCaseId.add(mst.SVMXC__Service_Order__c.Price__c);
    }
    }
   

}
I am trying to create this trigger:

trigger completeFirstResponseCaseComment on CaseComment (after insert) {

// Cannot be a portal user
if (UserInfo.getUserType() == 'Standard'){
  DateTime completionDate = System.now();
  List<Id> caseIds = new List<Id>();
  for (CaseComment cc : Trigger.new){
   // Only public comments qualify
   if(cc.IsPublished == true)
    caseIds.add(cc.ParentId);
  }
  if (caseIds.isEmpty() == false){
   List<Case> caseList = [Select c.Id, c.ContactId, c.Contact.Email,
            c.OwnerId, c.Status,
            c.EntitlementId, c.SlaStartDate,
            c.SlaExitDate
            From Case c
            Where c.Id IN :caseIds];
   if (caseList.isEmpty() == false){
    List<Id> updateCases = new List<Id>();
    for (Case caseObj:caseList) {
     // consider an outbound email to the contact on the case a valid first response
     if ((caseObj.Status == 'In Progress')&&
         (caseObj.EntitlementId != null)&&
         (caseObj.SlaStartDate <= completionDate)&&
         (caseObj.SlaStartDate != null)&&
         (caseObj.SlaExitDate == null))
      updateCases.add(caseObj.Id);
    }
    if(updateCases.isEmpty() == false)
     milestoneUtils.completeMilestone(updateCases, 'First Response', completionDate);
   }
  }
}
}

Then I try to create a milestoneutils class :

public class milestoneUtils {
   
    public static void completeMilestone(List<Id> caseIds, String milestoneName, DateTime complDate) {
     
    List<CaseMilestone> cmsToUpdate = [select Id, completionDate
                       from CaseMilestone cm
                       where caseId in :caseIds and cm.MilestoneType.Name=:milestoneName and completionDate = null limit 1];
    if (cmsToUpdate.isEmpty() == false){
      for (CaseMilestone cm : cmsToUpdate){
        cm.completionDate = complDate;
      }
      update cmsToUpdate;
    } // end if
  }
 
  // test methods
  static testMethod void testCompleteMilestoneCase(){
   
    Contact oContact = [select id from Contact limit 1];
    String contactId;
    if (oContact != null)
      contactId = oContact.Id;
   
    Entitlement entl = [select id from Entitlement limit 1];
    String entlId;
    if (entl != null)
      entlId = entl.Id;
   
    List<Case> cases = new List<Case>{};
    if (entlId != null){
      Case c = new Case(Subject = 'Test Case with Entitlement ', EntitlementId = entlId, ContactId = contactId);
      cases.add(c);
    }
   
    // Insert the Account records that cause the trigger to execute.
    if (cases.isEmpty()==false){
      insert cases;
      List<Id> caseIds = new List<Id>();
      for (Case cL : cases){
        caseIds.add(cL.Id);
      }
      milestoneUtils.completeMilestone(caseIds, 'First Response', System.now());
        }
    }
 
    static testMethod void testCompleteMilestoneViaCase(){
     
        // Perform data preparation
        Entitlement entl = [select id from Entitlement limit 1];
        String entlId;
        if (entl != null)
            entlId = entl.Id;
        List<Case> cases = new List<Case>{};
        for(Integer i = 0; i < 1; i++){
            Case c = new Case(Subject = 'Test Case ' + i);
            cases.add(c);
            if (entlId != null){
                c = new Case(Subject = 'Test Case with Entitlement ' + i, EntitlementId = entlId);
                cases.add(c);
            }
        }
       
        // Insert the Account records that cause the trigger to execute.
        insert cases;

        List<CaseComment> ccs = new List<CaseComment>{};
        for(Case c : cases){
            CaseComment cc = new CaseComment(CommentBody='TestPublic', IsPublished=true, ParentId=c.Id);
            ccs.add(cc);
            cc = new CaseComment(CommentBody='TestPrivate', IsPublished=false, ParentId=c.Id);
            ccs.add(cc);
        }
        if (ccs.isEmpty()==false)
            insert ccs;
   
    // Now create emailmessage objects for them.
   
        List<EmailMessage> emails = new List<EmailMessage>();
        for(Case c : cases){
            emails.add(new EmailMessage(parentId = c.id));
        }
        if(emails.isEmpty()==false)
            database.insert(emails);
       
        for(Case c : cases){
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            String[] toAddr = new String[] {'mramsey@salesforce.com'};
            mail.setToAddresses(toAddr);
            mail.setSaveAsActivity(false);
            mail.setTargetObjectId(c.ContactId);
            mail.setWhatId(c.Id);
            mail.setHtmlBody('TestHTMLBody');
            mail.setPlainTextBody('TestTextBody');
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
        }
   
    for(Case c : cases){
      c.Status = 'Closed';
    }
    update cases;
   
        // Query the database for the newly inserted records.
        List<Case> insertedCases = [SELECT Subject,
                                           Description,
                                          (SELECT IsPublished, CommentBody From CaseComments),
                                          (SELECT TextBody, Subject, Incoming From EmailMessages)
                                           FROM Case
                                           WHERE Id IN :cases];
    }
}

But still not luck, I get this error:
: Compile Error: Didn't understand relationship 'EmailMessages' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 103 column 36
Hello: I have a simplest test class to delete a single record, code below. I have checked the select statement via 'query editor' in developer console; it returns a valid id. I just can't figure out why my delete statement does not work!  My class passes the test alright, but when I go and check the line item under the parent opportunity, I can see the line item is there unaffected. Please advise! Thanks very much



@istest
public class del1
{
static testmethod void unittest() {
 
List<opportunitylineitem> ol = [select id from opportunitylineitem where id =: '00km0000001WVUSAA4'] ;
delete ol;

}
}
I am trying to get the URL of an image which I have uploaded on my rich text field of a custom object. Any ideas or pointers.
I'm using an Enterprise instance and am getting the following error ever time we try to edit or save a Phone number (Standard Field) on the Contact Object (Standard Object). The error is present even when entering valid us numbers (no dashes, letters, etc.)

Error:Apex trigger updateCustomObjects caused an unexpected exception, contact your administrator: updateCustomObjects: execution of AfterUpdate caused by: System.LimitException: Attempted to schedule too many concurrent batch jobs in this org (limit is 5).: Trigger.updateCustomObjects: line 73, column 1
Need salesforce job support for a project.

Anyone interested reply or send an email to salesfo401@gmail.com.

Thanks.
  • April 20, 2014
  • Like
  • 2