• Anupam Rastogi
  • SMARTIE
  • 752 Points
  • Member since 2014

  • Chatter
    Feed
  • 23
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 202
    Replies
Hello,

 I have to create one trigger on opportunityLineItem
I can't see opportunityLineItem  in setup/customize
how can I create trigger??????

i can't see pricebook entries tab also
how can i create record for pricebook entries

 
Newbie question.  I want to use Javascript to conditionally return values based on the incoming value from a Salesforce picklist field.
(I know I can make conditional fields in SF, but I want to figure out how to get a variable from what comes from SF so I can use it in javascript).

Here's the example without Salesforce fields that works fine:
<script>
var myfirst = 'This';
var mysecond = 'That';
var inpvariable = 'Banana';


if(inpvariable =='Coffee')
document.write(myfirst);
 else document.write(mysecond);
</script>
Here is what I want to do with an incoming picklist field
<div class = "mypage">
{!Opportunity.StageName}
</div>

<script>
var myfirst = 'This';
var mysecond = 'That';
var myother = 'Other';
var inpvariable = {!Opportunity.StageName}.value;


if(inpvariable =='Prospecting')
document.write(myfirst);
 else if (inpvariable =='Proposal/Price Quote')
document.write(second);
else
document.write(myother);
</script>
Help would be greatly appreciated.  Thanks in advance
 
I want to hide my save button (id="c2") when some one click one the edit button. i tried using j query, but it does not work. Does anybody have any idea? Thanks
 
<apex:pageblockButtons >
    <apex:commandButton action="{!doToggleEditMode}" value="Edit" reRender="myPanel" rendered="{!NOT(bEditMode)}" id="c1" />
    <apex:commandButton action="{!doSave}" value="Save" reRender="myPanel" rendered="{!bEditMode}" />
    <apex:commandButton value="PRINT" onclick="window.print();"/>
    <apex:commandButton value="Cancel" action="{!Cancel}"/>
    <apex:commandButton value="Save" action="{!save}" id="c2"/>
</apex:pageblockButtons>

Extension
 
public Boolean bEditMode {
get {
  if(bEditMode == null) {
      bEditmode = false;
      }
      return bEditMode;
  }
  set;
}

public PageReference doToggleEditMode() {
     bEditMode = !bEditMode;
        return null;
}

public PageReference doSave() {
    try {
    controller.save();
    doToggleEditMode();
    }
    catch(Exception ex) {
    }

    return null;
}

 
Hello,

 Account object has   territory field and affiliation child objects with lookup relation
how to write a trigger on territory field  object
i.e record has to be  inserted in  territory field  object when the lookup account has affiliation

could  you please give me a snapshot of code

Thanks in advance..
Is it possible to edit the email templates which we define in Salesforce. I want to edit the HTML Email template and send further.
Please suggest how to achieve this.
Hi Guys,

Any idea of how to pass a value to a loookup field on a visual force page. I tried passing it through URL and then pass it to the page using controller's getObject Method. Here is the code

My Url to Pass the Id of contact

apex/Fact_Find_Page_1?retURL=%2Fa0q%2Fo&save_new=1&sfdc.override=1?cid={!Contact.Id}
Here is my controller code:
public Fact_Find__c getFf() {

	     if(ff == null) ff = new Fact_Find__c();
     ff.Contact__c = ApexPages.currentPage().getParameters().get('cid');

	      return ff;

	    }
But this is not prefilling  the contact lookup field on the visual force page.

Can anyone let me know what is wrong in my code?
Thanks so much
 
  • May 06, 2015
  • Like
  • 0
I have written a trigger that creates a contact when a quote has been accepted.  It is working in Sandbox.  Here is the code:

trigger CreateContract on Quote (before update) {
    
   for(Quote q : trigger.new){
        

        if(q.Status == 'Accepted'){
            
      Account acct = [SELECT Id, Name, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry, ShippingStreet, ShippingCity, ShippingState, ShippingPostalCode, ShippingCountry FROM Account WHERE Id = :q.AccountId];
      Opportunity opp = [SELECT Id, Name, Total_MRC__c FROM Opportunity WHERE Id = :q.OpportunityId];
            
            List <Contract> co = [SELECT Id FROM Contract WHERE Opportunity__c = :opp.Id];
            List <Contract> cont = [SELECT Id FROM Contract WHERE Quote__c = :q.Id];
            if (cont.size() <= 0){

          Contract ct = new Contract();
            
            ct.AccountId = acct.Id;
            ct.Status = 'Draft';
            ct.Opportunity__c = opp.Id;
            ct.Quote__c = q.Id;
            ct.BillingStreet = acct.BillingStreet;
            ct.BillingCity = acct.BillingCity;
            ct.BillingState = acct.BillingState;
            ct.BillingPostalCode = acct.BillingPostalCode;
            ct.BillingCountry = acct.BillingCountry;
            ct.salesReach__Contract_Monthly_Billing__c = opp.Total_MRC__c;
                
            insert ct;
                
                opp.StageName = 'Contract Requested by Client';
                update opp;
            }
        }
                
    }
            
}

I am trying to write the associated test class so I can push to production.  However I keep getting failed statuses when I click "Run Test" such as:

System.DmlException: Update failed. First exception on row 0 with id 0Q01800000008xyCAA; first error:
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CreateContract: execution of AfterUpdate
caused by: System.QueryException: List has no rows for assignment to SObject
Trigger.CreateContract: line 8, column 1: []

Here is what I have so far for the test class:

@isTest
public class TestCreateContract {
    public static testmethod void TestUpdateChildAccounts(){
        Account a = new Account();
        a.Name = 'Test Account';
        a.salesReach__Agent_Account_Company_Name__c = '001a000001DbY9F';
        a.salesReach__Agent_Contact_Name__c = '003a000001XKLvE';
        a.BillingStreet = '1340 S Market St.';
        a.BillingCity = 'T or C';
        a.BillingState = 'NM';
        a.BillingPostalCode = '87901';
        a.BillingCountry = 'USA';
        a.ShippingStreet = '1340 S Market St.';
        a.ShippingCity = 'T or C';
        a.ShippingState = 'NM';
        a.ShippingPostalCode = '87901';
        a.ShippingCountry = 'USA';
        insert a;  
        
        Opportunity o = new Opportunity();
        o.Name = 'Telecom Potential Sale';
        o.AccountId = a.Id;
        o.salesReach__Agent_Account_Company_Name__c = a.salesReach__Agent_Account_Company_Name__c;
        o.salesReach__Agent_Contact_Name__c = a.salesReach__Agent_Contact_Name__c;
        o.CloseDate = date.today();
        o.StageName = 'Quote Requested By Client';
        o.Opportunity_Type__c = 'Renew Existing Service';
        o.Opportunity_Contact__c = '003a0000028fI7L';
        insert o;
        
        Quote q = new Quote();
        q.Name = 'Telecom Potential Sale - Quote';
        q.ExpirationDate = o.Quote_Expiration_Date__c;
        q.ContactId = o.Opportunity_Contact__c;
        q.Status = 'Draft';
        q.OpportunityId = o.Id;
        insert q;
        
        q.Status = 'Accepted';
        update q;
        
    }

}


Can someone please help me fix this?  Thank you!
How to send Notifications when Approval is reassigned?

Hi All,

Please help!
I am in new in SFDC and facing a issue please resolve it ASAP.its urgent.

Currently there is no actions in the Approval configuration that I can do to send an email alert when a user reassign the approval step to someone else.  Is there anyone who was able to archieve this by any other means? Thanks.

 
Is this possible?

from the trigger:

//call out to the class
returnStateAbbreviations f = new returnStateAbbreviations();
f.returnStateAbbreviations(stateName);

//attempt to return from class
 public with sharing class returnStateAbbreviations 
{  
    public string returnState(string stateName)
    { 
        String abbr;
        String stateAbbr;
        
        if(stateName=='Alabama')
        {
            stateAbbr = 'AL';            
        } //
// etc
        abbr = stateAbbr;
        return abbr;        
    }  

}

how would I then receive abbr back at the trigger?
Hi All,
I have got a Master Objtect which is application_Forcm__c and Detail/Child Object is Family_Detail__c.

Master child relation name is Family_Detail_Info.

Requirement:
Once user fills the Application page details and submits page redirects to Family detail Page where user enters Family deails which will be associated with the application form.
I am using controller extension on Family Detail page, and i want whatever Family Data entered by user it should be automaticaly mapped to Application form he submitted.

Basically i want to skip pressing search application button and selecting application form number as shown bellow.
User-added image
How can i do this suggest me please.

My Approch: From Application form page i am passing the Application form Id which user just submitted, And i will SOQL and get the Appliction From Number. But problem with this is i am not getting what name i should use in INSERT Statment of Family Detail so that application form number is mapped. 
Hi All,

I need help on creating Apex trigger Here is the scenario:
I am having two objects 1. Account  2. Account Branch with a master detail relation ship where Account is Master.
Fields:
Account Branch ->  Branch_Status__c.
Account           ->  Status, Client_Id__c and rollup summary field that will calculate number of Branchs under that account called         No_Of_Branches__c

Now My trigger has to update Account status as follows:
If Client_Id__c = 'X' and No_Of_Branches__c = 0 then Status = 'Closed Prospect'
If Client_Id__c contains SAP or PAS and No_of_Branches__c = 0 then status = Active
If Client_Id__c contains SAP or PAS and No_Of_Branches__c !=0 and Branch_Status_c!=Cancel then status = Active
(Here Branch_Status__c is a field of child object and trigger has to check status of Branches and have to determine cancel if all are on cancel state or not)
If Client_Id__c contains SAP or PAS and No_Of_Branches__c !=0 and Branch_Status__c==cancel then status = Inactive
(Here Branch_Status__c is a field of child object and trigger has to check status of Branches and have to determine cancel if all are on cancel state or not)

Can any one help to frame the trigger. The trigger has to be on the child object.

Thanks,

 
 
I have a server that needs to push changes up to a Salesforce DB several times per day. There is only one Salesforce 'user' involved with this task.

How do I implement OAuth, or use an alternative scheme, to handle this scenario, and allow me to use the REST API to complete this task?  I suppose if the access token could be made to be non-expiring that could work but I am hoping for a cleaner solution.

Thanks,
James
Hi,
I need to add discount to line item dynamically. For eg: If a customer orders mac + iphone it should add 10% discount, mac + samssung 15% discount, again mac + iphone + samsung 25% should get added. It should check for all possible products and its discount. Can anyone help me with it? 

Thanks,
Vetri
Can any one help me out. How to call 'n' no of USER profiles  and add error method in test class.In the trigger i do have users other than those users it should throw an error.so how do i use the users and the add error message in test classAny help very much appreciated.
Trigger :
trigger oli_multiple_products_before_insert on OpportunityLineItem (before insert) {

 Id userProfileId = userinfo.getProfileId();
  String userProfileName = [SELECT ID, Name from Profile Where Id = : userProfileId].Name;


  if( userProfileName != 'System Administrator' &&
      userProfileName !='Custom Marketing Users 10K 25K '&&
      userProfileName !='Customer Service User'&&
      userProfileName !='Fulfillment User'
     ) {


    for (OpportunityLineItem oli : Trigger.new) {
        if (Trigger.isInsert) {



            Integer line_Count = [SELECT COUNT()
                                    FROM OpportunityLineItem o
                                    WHERE o.OpportunityId = :oli.OpportunityId
                                    AND o.PriceBookEntryId = :oli.PriceBookEntryId  ];

            if (line_Count > 0) {
                oli.addError('A Product can not be added more than once to the Opportunity.');
         }                    
        }
    }
  }
 }
TestClass :
@isTest
    private class Oli_multiple_Products_TestClass{
    static testmethod void ValidateOlimultipleproducts(){
    Date closeDt = Date.Today();

//Find user with Profile = Sales and Service
        Profile SalesNService = [Select id from Profile where Name = 'Sales and Service' limit 1];
        User u = new User(
            Alias = 'standt', 
            Email='standarduser@testorg.com',
            EmailEncodingKey='UTF-8',
            LastName='Testing',
            LanguageLocaleKey='en_US',
            LocaleSidKey='en_US',
            ProfileId = SalesNService.Id,
            TimeZoneSidKey='America/Los_Angeles',
            UserName='standarduser@testorg.com'
        );


    Account acc = new Account (Name ='TestClassAccountOpportunitySegment', Region__c = 'AM', Persona__C = 'Artisan');
    //System.debug('AccountOpportunitySegment before insert of new Account: ' + acc.segment__C);
    insert acc;

    Opportunity opp = new opportunity (Name ='TestclassAccountOpportunitySegment', AccountId= acc.Id, StageName = 'Prospecting', 
                                       CloseDate = closeDt, ForecastCategoryName = 'Pipeline');
    insert opp;                                 

    OpportunityLineItem ooli = new OpportunityLineItem (Quantity=2, OpportunityId=opp.Id, TotalPrice=10, PriceBookEntryId='01ud0000004YWFqAAO');
    insert ooli;

    OpportunityLineItem ooli1 = new OpportunityLineItem (Quantity=2, OpportunityId=opp.Id, TotalPrice=10, PriceBookEntryId='01ud0000004YWFzAAO');
    insert ooli1;

    }
    }



 
  • April 22, 2015
  • Like
  • 0
Hi Experts,
 
I need a trigger help.
Two objects having lookup relationship.
Parent Object - Case
Child Object - Candidate_Task__c
Child object having one custom number field   Resource_incurred_hours_Update__c.
Parent object having one custom number field   Total_Hours_Update__c.
I need to calculate the sum of all “Resource incurred hours” field values and populate in “Total Hours” field.
Please find the below image and trigger.

Case Object and Custom Object (Project - Task - Resource):

Case and Custom Object (Project - Task - Resource)

Trigger:

trigger RollUpIncurredHours on Candidate_Task__c (after delete, after insert, after update) {
 
  //Limit the size of list by using Sets which do not contain duplicate elements
  set<iD> ProjectTaskResourceIds = new set<iD>();
 
  //When adding new Incurred Hours or updating existing Incurred Hours
  if(trigger.isInsert || trigger.isUpdate){
    for(Candidate_Task__c p : trigger.new){
      ProjectTaskResourceIds.add(p.Resource_incurred_hours_Update__c);
    }
  }
 
  //When deleting Incurred Hours
  if(trigger.isDelete){
    for( Candidate_Task__c p : trigger.old){
      ProjectTaskResourceIds.add(p.Resource_incurred_hours_Update__c);
    }
  }
 
  //Map will contain one ProjectTaskResource Id to one sum value
  map<Id,Double> ProjectTaskResourceMap = new map<Id,Double> ();
 
  //Produce a sum of Resource_incurred_hours_Update__c and add them to the map
  //use group by to have a single ProjectTaskResource Id with a single Incurred Hours
  for(AggregateResult q : [select sum(Resource_incurred_hours_Update__c)
    from Candidate_Task__c where Candidate_Task__c IN :ProjectTaskResourceIds group by Candidate_Task__c]){
      ProjectTaskResourceMap.put((Id)q.get('Candidate_Task__c'),(Double)q.get('expr0'));
  }
 
  List ProjectTaskResourceToUpdate = new List();
 
  //Run the for loop on ProjectTaskResource using the non-duplicate set of ProjectTaskResource Ids
  //Get the sum value from the map and create a list of ProjectTaskResource to update
  for(Candidate_Task__c o : [Select Id, Resource_incurred_hours_Update__c from Candidate_Task__c where Id IN :ProjectTaskResourceIds]){
    Double IncurredHoursSum = ProjectTaskResourceMap.get(o.Id);
    o.Resource_incurred_hours_Update__c = IncurredHoursSum;
    ProjectTaskResourceToUpdate.add(o);
  }
 
  update ProjectTaskResourceToUpdate;
}
 
Anyone sort out my issue. Thanks in advance.
 
Thanks,
Manu
Hi,
I am using REST API call to get SF account details. I am able to get OAuth token, but when I use this token to get Account details it gives below rror.

[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]



Here  is the flow

Request:https://ap1.salesforce.com/services/oauth2/token?grant_type=authorization_code&code=aPrxqJ8A8kLOza8Stjpv6sovqPjwgt9wJxzcIaPRsCnGPyxvpLJSOUhmEHkQ7qCNO84np7gXZQ%3D%3D&client_id=3MVG9ZL0ppGP5UrBx8LU.vAPd80ozIo4JMB66N3r1IPzsiMMPzIYm3pklapNDhi24wcd3Ik8JtlQZqr_opatH&client_secret=5390506801126798324&redirect_uri=https://local/user/connector/generic/redirectoauth


Response:
{"id":"https://login.salesforce.com/id/00D28000000KMl1EAG/00528000000MwpQAAS","issued_at":"1428631322872","scope":"id full custom_permissions api web openid visualforce refresh_token chatter_api","instance_url":"https://ap2.salesforce.com","token_type":"Bearer","refresh_token":"5Aep861TSESvWeug_wBae_.NiEYtLVbgA9FW1UDMAq7zqGYpEeyCgRS1jLbqFuSuC2vJd5RyDOmpU.pSPn.Q1zV","id_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjE5NCJ9.eyJleHAiOjE0Mjg2MzE0NDIsInN1YiI6Imh0dHBzOi8vbG9naW4uc2FsZXNmb3JjZS5jb20vaWQvMDBEMjgwMDAwMDBLTWwxRUFHLzAwNTI4MDAwMDAwTXdwUUFBUyIsImF0X2hhc2giOiJlbF9iOXBzSlJCMVFOMGI5cXJib0V3IiwiYXVkIjoiM01WRzlaTDBwcEdQNVVyQng4TFUudkFQZDgwb3pJbzRKTUI2Nk4zcjFJUHpzaU1NUHpJWW0zcHRsYXBORGhpMjR3Y2QzSWs4SnRsUVpxcl9vcGF0SCIsImlzcyI6Imh0dHBzOi8vbG9naW4uc2FsZXNmb3JjZS5jb20iLCJpYXQiOjE0Mjg2MzEzMjJ9.XXfxxvNwQgWrSP-eFoUhFbzDfqxsASntM1slTjhQXN_vgHAp-Wv0rJYBWg6QXcIWwQEsvfCAvGi9JkbRIZ5UYqLPSrnhxsje4StPfvwwHMBMarimqeKKWt24Xb6Hri0DMdp6FjN9y9RneJpVcZeLHbkFnOIUf11cgMk1d3kI9KrgmkoDn8TI1yfPU0NLbJtafnYw2S9cdHrcju31i-9eLjy-yeMrJtinS5TqUdWcalEL1uqZq_KGEnsWkmN8sjEaSgtCio33ZZwDL6IKTgdHeDZedEZfRqhUoyBni14qYdpRX9ANSd1B61HtCVLiAeetc156KB4KYr-oR0Byg7oqAswhU41OQ9RmNp5VDQVVKspgwImauJzhpLs59W64SH5dP
h4xn5SF7fCGK534idYP_HQOey2KxBNrS5ATOATbNHsDt0maztiPK0K8rNjjnARya8QCqPJoumeJddchsmYhMIWPrxtwzNdpPXMuSz3hY3xIALFf0cDW_OwBPWT4P3_KZqfE7w0lPihzwhTwHy4tSu_kq4t4ikMu-xc6TNkZoy4HJP_qNZ7f7CCENHvUHjF_vgjSqNcPVJnpp-g3ImN6eBbstsndoktkdxpSC8N34WyWwKxiC5S5NVtgJBbLI2J9Q8xdBvcArvvoANt6_nhjsDf6417kRstohZio1aOoSW8","signature":"3yrSoEaIoCEtGXZpMHaLnV8B6z/njamvHSPTOHUB9ME=","access_token":"00D28000000KMl1!ARAAQPLIuaRCKyXQPB1LDjuiF4Bg1QAVfzXNFpq7C4zYRVurh3JxqYpcu5IIf98P1XOB7oEwLkbSJwdq4Mc0pxkmaQCbjbgd"}

token 00D28000000KMl1!ARAAQPLIuaRCKyXQPB1LDjuiF4Bg1QAVfzXNFpq7C4zYRVurh3JxqYpcu5IIf98P1XOB7oEwLkbSJwdq4Mc0pxkmaQCbjbgd
Request:https://ap1.salesforce.com/services/data/v31.0/query?q=SELECT+Name+From+User+WHERE+Id='00528000000MwpQAAS'
Authorization:Bearer 00D28000000KMl1!ARAAQPLIuaRCKyXQPB1LDjuiF4Bg1QAVfzXNFpq7C4zYRVurh3JxqYpcu5IIf98P1XOB7oEwLkbSJwdq4Mc0pxkmaQCbjbgd

Error while sending Salesforce request {}HTTP_401 : [{"message":"Session expired
 or invalid","errorCode":"INVALID_SESSION_ID"}]


Thanks,
Veera.
Hello,

Im new here and looking for some help to build a process builder.
Basically, I would like to have a case created every time a client respond to a close case by email.
If someone has any idea on how to setup that in Lightening process builder.

Thanks
Hi All,

Can any one guide me how to write a trigger on Account that has to create a task record (Only one record) and then send an email notification to the person who is in assgined to field. I wrote an after update trigger but it is creating multiple task records when ever i am editing account page for any reason.
Thanks!
Hi All,

I am trying to subtract two datetime fields but i got below error message,
" Date/time arithmetic expressions must use Integer, Decimal or Double arguments "

My code is in below

CronTrigger ct = [SELECT Id,NextFireTime,starttime, CronJobDetail.name FROM CronTrigger where CronJobDetail.name = 'samplejob001' limit 1];
integer temp =  ct.NextFireTime - ct.starttime;
System.debug('=====>'+temp);

Please guide me, how to solve this issue.
 
Hi,

I have the following task...

We have a pick list containing colors (red,green,blue...)
We have another field which changes its Backgound color based on the color selected from first field...

I need to achieve this without code...

Can i use formula field...? If yes then what would be the formula...?
Hi Everyone,

I am new to Salesforce coding and learning to integrate with Salesforce. I am facing issue as mentioned below.

Scenario - I am integrating two Salesforce instance using APEX Callout and REST API. In the source SFDC instance I have created a trigger on the Account Object that calls a class with @future annotation. This class sends out a HTTP Request to the other SFDC instance using Web Server Authentication Flow.

Issue Description - Per the defined steps in 'Getting Started with the Force.com REST API' guide, I create a Connected App record in the Destination SFDC instance. But when the APEX code is requesting the Salesforce Authorization Endpoint with the relevant parameters (response_type, client_id, redirect_uri), I am not able to retrieve the Authorization Code (Code) that comes along with the Callback URL.
Though, I am successfully redirected to the callback URL (appended with the code) when I am using a browser. See below the request and the redirected response I get when I do it in a browser - 
HTTP Request:
https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=[client_id taken from the Connected App record]&redirect_uri=https://localhost:8443/RestTest/oauth/_callback&immediate=true
HTTP Response:
http://localhost:8443/RestTest/oauth/_callback?code=[aPrxg.........]%3D%3D

Problem Statements - 
1. On the first place, is it possible to programmatically extract the code from the HTTP response?

2. If the answer to the above question is 'Yes', then please suggest, how? What are the relevant methods to extract this information.

Thanks
Anupam
Hello,

 I have to create one trigger on opportunityLineItem
I can't see opportunityLineItem  in setup/customize
how can I create trigger??????

i can't see pricebook entries tab also
how can i create record for pricebook entries

 
Newbie question.  I want to use Javascript to conditionally return values based on the incoming value from a Salesforce picklist field.
(I know I can make conditional fields in SF, but I want to figure out how to get a variable from what comes from SF so I can use it in javascript).

Here's the example without Salesforce fields that works fine:
<script>
var myfirst = 'This';
var mysecond = 'That';
var inpvariable = 'Banana';


if(inpvariable =='Coffee')
document.write(myfirst);
 else document.write(mysecond);
</script>
Here is what I want to do with an incoming picklist field
<div class = "mypage">
{!Opportunity.StageName}
</div>

<script>
var myfirst = 'This';
var mysecond = 'That';
var myother = 'Other';
var inpvariable = {!Opportunity.StageName}.value;


if(inpvariable =='Prospecting')
document.write(myfirst);
 else if (inpvariable =='Proposal/Price Quote')
document.write(second);
else
document.write(myother);
</script>
Help would be greatly appreciated.  Thanks in advance
 
Hello,

i'd like to have a user from a picklist field in the case (let's call him user 1) automatically follow a case the moment it's created so he gets feed update in his chatter.

Anyone can help me with that?

Thanks1
I want to hide my save button (id="c2") when some one click one the edit button. i tried using j query, but it does not work. Does anybody have any idea? Thanks
 
<apex:pageblockButtons >
    <apex:commandButton action="{!doToggleEditMode}" value="Edit" reRender="myPanel" rendered="{!NOT(bEditMode)}" id="c1" />
    <apex:commandButton action="{!doSave}" value="Save" reRender="myPanel" rendered="{!bEditMode}" />
    <apex:commandButton value="PRINT" onclick="window.print();"/>
    <apex:commandButton value="Cancel" action="{!Cancel}"/>
    <apex:commandButton value="Save" action="{!save}" id="c2"/>
</apex:pageblockButtons>

Extension
 
public Boolean bEditMode {
get {
  if(bEditMode == null) {
      bEditmode = false;
      }
      return bEditMode;
  }
  set;
}

public PageReference doToggleEditMode() {
     bEditMode = !bEditMode;
        return null;
}

public PageReference doSave() {
    try {
    controller.save();
    doToggleEditMode();
    }
    catch(Exception ex) {
    }

    return null;
}

 
Hello,

 Account object has   territory field and affiliation child objects with lookup relation
how to write a trigger on territory field  object
i.e record has to be  inserted in  territory field  object when the lookup account has affiliation

could  you please give me a snapshot of code

Thanks in advance..
Hi,

I have a button in a visualforcepage which is an inline visualforce page embedded in a standard page layout.

On the button click i just want to refresh the visualforce page not the entire standard page.

How can i do it.

Thanks,
Hello All,
I am doing an api callout to an 3rd party website and i am writing an schedule class for that. while executing that scheduled calss i am getting the above error saying that you have some uncommitted work pending,please commit before rolling out. I have googled a lot about this and seems like we cannot callout after performing an Dml operations,

But in my code i am not able to seperate Dml and callout. Even i added @future annotation before the method which i used for Callout. It is retrieving the details of the first record after that when going to the second callout it is giving that error.

Basically it is following the unstructured format like doing a callout first and doing DML after that and again going for the callout- Which seems like not a best practice. So any suggestions in code will be a huge help.
@future(callout=true)
    public static void processAllOpenRequisition(){
        bulkify  = true;
       u = [SELECT Username_Broadbean__c,Password_Broadbean__c From USER WHERE id =:UserInfo.getUserId()];
        HttpRequest req = new HttpRequest();
        req.setMethod('POST');
        req.setEndpoint('https://api.adcourier.com/hybrid/hybrid.cgi');
        req.setHeader('Content-Type', 'text/xml');
        requisitionRecMap = new Map<id, Recruiting_Activities__c>([SELECT  Time_now__c,Time_From__c FROM Recruiting_Activities__c WHERE EL_Status__c <> 'Closed' AND REcordtype.Name=:'Requisition' ]);
        system.debug('hellooooo'+requisitionRecMap);
          readObject(requisitionRecMap.keySet()); --> Here calling the another method for XML
           req.setBody(xmlData); 
            Http http = new Http();
            req.setTimeout(60000);
             if(!test.isrunningtest()){
                HttpResponse res = http.send(req);
                resbody = res.getBody();
                System.debug('*****'+res.getBody()); // Here you will get the response
             } 
       
            parseTest(); --> It is the method for parsing the data, here we are doing DML operations.
    }
    
    
 public static void readObject(Set<Id> recids){ 
   for(Recruiting_Activities__c ra:[SELECT  Time_now__c,Time_From__c,Req_ID__c  FROM Recruiting_Activities__c where Id IN:recids]){
       JobReference=ra.Req_ID__c;
       xmlData+='<?xml version="1.0" encoding="utf-8" ?>'
                +'<AdCourierAPI>'
                +'<Method>RetrieveApplications</Method>'
                +'<APIKey>3012861772</APIKey>'
                +'<Account>'
                    +'<UserName>'+u.Username_Broadbean__c+'</UserName>'
                    +'<Password>'+u.Password_Broadbean__c+'</Password>'
                +'</Account>'
                +'<Options>'
                    +'<Filter>'
                        +'<JobReference>'+JobReference+'</JobReference>'
                        +'<Times>'
                            +'<TimeFrom>ra.Time_From__c</TimeFrom>'
                            +'<TimeTo>2020-12-24T06:15:00Z</TimeTo>'
                        +'</Times>'
                        +'<Id></Id>'
                        +'<Rank>All</Rank>'
                    +'</Filter>'
                    +'<BodyFormat EncodingType="None" />'
                    +'<EmbedDocuments EncodingType="Base64">true</EmbedDocuments>'
                   +'<XMLFormat EncodingType="Base64">BGT</XMLFormat>'
                    +'<IncludeAddress>false</IncludeAddress>'
                +'</Options>'
            +'</AdCourierAPI>';
       system.debug('--------'+xmlData);
   }     
    
 }

 
Hai,
Q) i have two standard objects Account and Contact,Requirment is Display the  Count of Contact on account obj by using custom field Count_of_con. trigger have write. anyone send the code.advanced thanks
 
Is it possible to edit the email templates which we define in Salesforce. I want to edit the HTML Email template and send further.
Please suggest how to achieve this.
Since you can not use workflows to send an email update on a Event, I am working on creating a trigger that will send email.  I created an email template called MCC_Close_Event_Email and based it on the Event object.  I tested it and made sure it pulls all the correct info when sending.  

Then I created the trigger below to send the email when a cretain field is checked.  
trigger EventSendEmailMCCReminder on Event (After Update, After Insert) {

/*  Event e1 = trigger.new[0];  */
    For (Event e1 : trigger.New){
  String[] toAddresses = new String[] {e1.owner.email};
  String[] strProfile = New String[] {e1.owner.profile.name};    
  Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

  mail.setTargetObjectId(e1.OwnerID);
  mail.setSenderDisplayName('Salesforce Admin');
  mail.setUseSignature(false);
  mail.setBccSender(false);
  mail.setSaveAsActivity(false);  
  
  System.debug('Profile Name ' + e1.owner.profile.name);
  System.debug('Owner Name ' + e1.owner.name);  
  System.debug('Profile Name ' + strProfile);
  System.debug('To Address ' + toAddresses);        
    
	If(e1.SendMCCRemiderEmail__c == True ){
 /*       If(e1.owner.profile.name == 'System Administrator'){ */
		EmailTemplate et=[Select id from EmailTemplate where DeveloperName=:'MCC_Close_Event_Email'];
        mail.setTemplateId(et.id);
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});         
    }   
    }  
}
My issue is, it send the email, but all the Event related fields in the email are blank.  Also, all me System.Debug values are blank in the debug log.  

Any ideas to ensure the Event related fields in the Email are populated?
 
Dear All,

Here i am posting a challenging question for all salesforce developers.

Can we fetch Data from Parent to child and child to sub child, sub child to child?

Let me explain you bit more:
 have Parent table A and child is B 
                           B having relation ship with C
                           C having relation ship with D
Now my question is i need to get data of A + B + C+ D by using SOQL query

Note: we need to get data by writing SOQL Query only not in using apex list or map

Highly apreciable your valueble answers

Thanks,


 
From standard functionality of converting lead, how can i create only contact. No account records should be created.
I tried but account is mandatory, is there any way i can skip the creation of account and just create contact.
Hi all, I am new to coding and could use some help. I am trying to develop a vf page for a custom object I created. I have 10 custom text fields to enter material names, the catch is I only want to initially show 5 fields, then click a button or link to add the remaining 5 fields if necessary. Is it possible? Thanks!