• VineetKumar
  • SMARTIE
  • 1903 Points
  • Member since 2013
  • Senior Developer
  • NSI Gulf


  • Chatter
    Feed
  • 60
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 832
    Replies
I'm very new to Salesforce and have written a class to export an opportunity to csv. It now exports correctly but when trying to write a test class I'm getting the above error when trying to reference the method within my class. I'm also not sure what to write for the assert method. As I'm new to this I'm really lost, any help would be appreciated.

exportCSV class:

public with sharing class exportCSV {
    public string header{get;set;}
    public String currentRecordId {get;set;}
    public String rId {get;set;}
    public List<Opportunity> AllOpenOpportunities {get; private set;} 
    public exportCSV() {
        header = 'Acc_Ref__c,Purchase_Order_Number1__c,Position__c,Total_Hours_Required__c,Shift_Start_Date__c,Shift_End_Date__c,Number_of_Shifts__c,Hours_per_Shift__c,Shift_Time__c,Pay_Code__c,Opportunity_Unique_Reference__c\r';
        rId  = ApexPages.currentPage().getHeaders().get('Referer');
        Id currentRecordId = rId.right(15);
        AllOpenOpportunities = [SELECT id, Name, Acc_Ref__c, Purchase_Order_Number1__c, Position__c, Total_Hours_Required__c, Shift_Start_Date__c, Shift_End_Date__c,Number_of_Shifts__c,Hours_per_Shift__c,Shift_Time__c,Pay_Code__c, Opportunity_Unique_Reference__c
                            FROM Opportunity 
                            WHERE id =: currentRecordId];
    }
}


Test class so far:

@isTest                    
public class TestClassOne {

    public static testMethod void testMethodOne() {
        // Create Account Data
        Account acc = new Account(Name='TestAcc');
        insert acc;

        // Create Opportunity Data
        Opportunity opp = new Opportunity(Name='Test Opp', AccountId=acc.Id);
        insert opp;
        system.currentPageReference().getParameters().put('currentRecordId', opp.Id);
        exportCSV conObj = new exportCSV();
        Test.startTest();
        // Call Methods of the class
        conObj.exportCSV();
        Test.stopTest();
        // Write assert statements
    }   
}

 
We updated our API with our mydomaiin url and after testing it worked fine.  24 hours later it is not working.  Here is the error message.

 Salesforce<br><br>[05:18:12]<br><br>[Guest]<br><br>Lead Create Connection Error<br>SoapFault exception: [soapenv:Client] No operation available for request {urn:partner.soap.sforce.com}login in

We tried to roll back to the previous url, which is a salesforce instance server name, but that did not fix the problem, although it worked previously.
I am quite new for salesofrce and I want to write a trigger to modify attachments name after user inserting the attachments. For my situation, my page is form for public input their information. It includes 3 question that requires users to insert attachments. One question can allow users to upload 1-3 attachmetns, and the other two require only 1. Since I want to classify them from the their name, I want a trigger to rename the attachments after insert. Thank you for your great effort.
Hello,
I have created a custom button on Opportunity. The custom button has following javascript code. When the user clicks on the button the email should be sent. and it is working fine. But I am not able to see the fields which is bind on template. How can i show or generate opportunity fields on email ?
Any suggestion would be helpful.
Thank you in Advance,
Yunus Kalam
 
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")} 
(function() {
sforce.connection.sessionId = "{!$Api.Session_ID}";
var message = new sforce.SingleEmailMessage();
message.targetObjectId = "{!Opportunity.ContactId__c}";
message.templateId = "00X7E000000EF6w";
message.saveAsActivity = true;
var result = sforce.connection.sendEmail([message]);
  if(result[0].success == 'true') {
     alert("Email has sent succesfully...");
  } else {
     alert("Failed...");
  }
alert(result);
}());


 
Hi Team,

How to create a validation rule for below requirement:

Block opportunity with stage from C5-Closed Won onward, which means once Opportunitys stage is up to C5-Closed Won, its owner can't change back stage to  C4/C3/C2/C1.

Can any one please help us.

Thanks in Advance
  • August 02, 2016
  • Like
  • 0
Hello All,
       I have a Custom VF page with 2 <apex:pageBlock> sections. One page block section is for data entry and the other is for showing a list of records. I have used reRender on selectOptions to re-render a page block having the list table. But when I change the value in the filter, the page block does not refresh and on the browser console, I get the following error "VFMetadataSender.js:65 Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://welcometomyorg-dev-ed.my.salesforce.com') does not match the recipient window's origin ('null')."

However, if I remove the first page block section then the code works absolutely fine. What am I missing when using multiple pageBlocks?????

Below is the code::

<apex:page standardController="Contact" recordSetVar="contacts">
    
    <apex:form >
        <apex:pageBlock title="Create a New Contact" id="pb1">
            <apex:pageBlockSection title="Primary Details">
                <apex:inputField value="{! Contact.FirstName}"/>
                <apex:inputField value="{! Contact.LastName}"/>
                <apex:inputField value="{! Contact.Email}"/>         
            </apex:pageBlockSection>    
               <apex:pageBlockButtons >
                <apex:commandButton title="Create Contact" value="Save" action="{! save}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
        
        <apex:pageBlock title="Contacts List" id="pb">
            <!-- Add a Filter-->
            Filter:
            <apex:selectList value="{! filterId}" size="1">
                <apex:selectOptions value="{! listViewOptions}"></apex:selectOptions>
                <apex:actionSupport event="onchange" reRender="pb"/>
            </apex:selectList>
            <apex:pageBlockTable value="{!contacts}" var="c" id="contactsTable">
                <apex:column value="{!c.FirstName}"/>
                <apex:column value="{!c.LastName}"/>
                <apex:column value="{!c.Email}"/>
            
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>    
</apex:page>
 
Hello,
We are looking into the possibility of adding a custom related lists on one of our custom object. I also need to add a button in the custom related list called 'Edit', so when clicks the button , the user is taken to another VF page to edit or add information to the related list.
Has anyone implemented any such similar functionality in their org?
Based on  my research, adding the hover link at the top of the page is not possible? Is this true?

If I use a visual force page to display the custom related list as a page block table, how can I add this cutom related list at the bottom of the detail page of the custom object?
 
Hello,

An user does not have access to the "custom links" option which apeears on home page above "recycle bin", how can i add access to this for an user ?

thanks for suggestion
  • July 25, 2016
  • Like
  • 0
Hi,

Can anyone clarify me When to use Triggers and When to use Validation Rules?

Explain with scenario is Appreciable...
I am finishing up my code and the last problem I haven't been able to solve is: when the final task for a lead is completed, I want the lead status to be updated. I have the task whoId field value, but I don't know how to use this value to access and update the lead that the task is related to. This is my code so far:
trigger Scheduler on Task (after insert, after update) {
    // Iterate through all tasks
    for(Task t : Trigger.new){
        // Schedule follow up task for completed tasks depending on task subjecct
        if(t.Status == 'Completed'){    
            if(t.Subject == 'Send Initial Email'){
                Task newTask = new Task(Subject = 'Make Initial Phone Call', IsReminderSet = True, ReminderDateTime = System.now()+1, Activitydate = System.now().date().addDays(1), WhoId = t.WhoId, ownerId = t.ownerId);
                insert newTask;
            } else if(t.Subject == 'Make Initial Phone Call'){
                Task newTask = new Task(Subject = 'Send Email #2', IsReminderSet = True, ReminderDateTime = System.now(), Activitydate = System.now().date(), WhoId = t.WhoId, ownerId = t.ownerId);
                insert newTask;
            } else if(t.Subject == 'Send Email #2'){
                Task newTask = new Task(Subject = 'Make Phone Call #2', IsReminderSet = True, ReminderDateTime = System.now(), Activitydate = System.now().date().addDays(1), WhoId = t.WhoId, ownerId = t.ownerId);
                insert newTask;
            } else if(t.Subject == 'Make Phone Call #2'){
                Task newTask = new Task(Subject = 'Send Email #3', IsReminderSet = True, ReminderDateTime = System.now(), Activitydate = System.now().date(), WhoId = t.WhoId, ownerId = t.ownerId);
                insert newTask;
            } else if(t.Subject == 'Send Email #3'){
                Task newTask = new Task(Subject = 'Make Phone Call #3', IsReminderSet = True, ReminderDateTime = System.now(), Activitydate = System.now().date().addDays(1), WhoId = t.WhoId, ownerId = t.ownerId);
                insert newTask;
            // When final task is completed, change lead status to 'unresponsive'
            } else if(t.Subject == 'Make Phone Call #3'){
                
                Lead myLead = [SELECT Id, Status FROM Lead WHERE Id = :t.whoId];       
                
                myLead.Status = 'Unresponsive';
                
                update myLead;
            }
        }    
    }
}

Any help would be greatly appreciated. Thank you!
String strObjProsPrefix = Schema.MCPM_Prospect__c.getSobjectType().getDescribe().getKeyPrefix();
        String strQuery = 'Select Id, MCPM_Email_Reminder_Interaction__c, MCPM_Prospect_Email_For_Reminder__c, '+
                                  'MCPM_Premise_Lookup__c, MCPM_Prospect__c'+  
                                  'from MCPM_Interaction__c where ';
        if(strRecordId.startsWith(strObjProsPrefix)){
            strQuery += 'MCPM_Prospect__c=  \''+String.escapeSingleQuotes(strRecordId)+'\' and '+
                         'MCPM_Email_Reminder_Interaction__c  = true ' +
                                                          'ORDER BY CreatedDate DESC LIMIT 1 ';
        }                                                 
        else{
            strQuery += 'MCPM_Premise_Lookup__c= \''+String.escapeSingleQuotes(strRecordId)+'\' and ' +
                                 'MCPM_Email_Reminder_Interaction__c = true'+ 
                                                          'ORDER BY CreatedDate DESC LIMIT 1 ';
        }                                                
                                                          
        List<MCPM_Interaction__c> objInterction = Database.query(strQuery);


Hi I am getting above error, tried many thing don't know what's going wrong.
Please help,
 
The controller compile error is  "Return value must be of type: List".  Thanks everyone for your help, much appreciated.

Part of VF template code:
<apex:repeat var="CurrItem" value="{!relatedto.BMCServiceDesk__Incident_Histories__r}">
<apex:outputPanel rendered="{!CurrItem.BMCServiceDesk__actionId__c = 'Notes'}">
<tr> <td colspan="4" class="hdr"><pre>{!CurrItem.BMCServiceDesk__note__c}</pre>&nbsp;
<apex:outputText value="{0,date,MM/dd/yyyy h:mm a}"> <apex:param value="{!CurrItem.BMCServiceDesk__date__c - (5/24)}"/></apex:outputText></td> </tr> </apex:outputPanel> </apex:repeat>

Controller:
public class sortedController {
    
    public ID attributeNoteID {get; set;}

    public List<Note> getNote() {

       Return [         
            SELECT Id, BMCServiceDesk__note__c, BMCServiceDesk__date__c
            FROM BMCServiceDesk__IncidentHistory__c
            WHERE BMCServiceDesk__actionId__c = 'Notes' AND BMCServiceDesk__incidentId__c = :this.attributeNoteID
            ORDER BY BMCServiceDesk__date__c DESC
        ];

    }
}

 
hello, I am creating process builder. in which i m using picklist in rule criteria. this picklist is in lead generation(Web-to-lead) form. If location equals to USA, UK, India or canada then mail of lead generation will send to user in my org.
I have created rule like
location equals USA
location equals UK
location equals India
location equals Canada
and then in action i have choosed email alert. In email alert i have selected name of user in my org. But no email delivered to him. I am not getting where i am doing mistake.
 
Hi,

I have wrapper class and test class. My code coverage is 38%. Can anyone help me to increase code coverage.

Apex class is 
public with sharing class OpportunityLineItemsNew {
    public List<Package__c> selectedPackages = new List<Package__c>();
    public Package__c prdcat{get;set;}
    public List<Package__c> checkedPackages{get;set;}
    List<packagewrapper1> packagesListNew = new List<packagewrapper1>();
    public List<packagewrapper1> packages {get;set;}
    public List<Package__c> filteredList = new List<Package__c>();
    String opprid = System.currentPageReference().getParameters().get('id');
    public set<Id> AccountSelectedSet;
    public OpportunityLineItemsNew(ApexPages.StandardSetController controller) {
        prdcat = new Package__c();
        AccountSelectedSet = new set<Id>();
        checkedPackages = new List<Package__c>();
        packagesListNew = new List<packagewrapper1>();
        packages = new List<packagewrapper1>();
        
        for(Line_Item__c chpack: [select Id, Name, Package__c,Product_Category__c,Activity__c,Cost__c,Final_Price__c,No_of_Days__c,No_Of_People__c,No_of_Male__c,No_of_Female__c,Total_Price__c,Comments__c from Line_Item__c where Opportunity__c = :opprid]){
            Package__c exisOpprLineItems = new Package__c();
            exisOpprLineItems.Name = chpack.Name;
            exisOpprLineItems.Product_Category__c = chpack.Product_Category__c;
            exisOpprLineItems.Activity__c = chpack.Activity__c;
            exisOpprLineItems.Cost__c = chpack.Cost__c;
            exisOpprLineItems.Final_Price__c = chpack.Final_Price__c;
            exisOpprLineItems.No_of_Days__c = chpack.No_of_Days__c;
            exisOpprLineItems.No_Of_People__c = chpack.No_Of_People__c;
            exisOpprLineItems.No_of_Male__c = chpack.No_of_Male__c;
            exisOpprLineItems.No_of_Female__c = chpack.No_of_Female__c;
            exisOpprLineItems.Total_Price__c= chpack.Total_Price__c;
            exisOpprLineItems.Comments__c = chpack.Comments__c;
            checkedPackages.add(exisOpprLineItems);
            AccountSelectedSet.add(chpack.Package__c);
        }
    }

    public List<packagewrapper1> getPackages(){
        if( prdcat.Product_Category__c != null ){
            filteredList = [SELECT Id,Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c,Final_Price__c,No_of_Days__c,No_Of_People__c,No_of_Male__c,No_of_Female__c,Total_Price__c,Comments__c FROM Package__c 
               where Product_Category__c=:prdcat.Product_Category__c ];
        } else {
            filteredList = [SELECT Id,Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c,Final_Price__c,No_of_Days__c,No_Of_People__c,No_of_Male__c,No_of_Female__c,Total_Price__c,Comments__c FROM Package__c ];
        }
        for(Package__c a : filteredList ){
            if(AccountSelectedSet.contains(a.Id)) {
            } else {
                packages.add(new packagewrapper1(a));
            }
            packages.add(new packagewrapper1(a));
        }
        
        return packages;
    }
    
    public  PageReference  filterPackagess(){
        packages.clear();
        return null;
    }

    public Package__c getPrdcat() {
        prdcat = new Package__c();
        return null;
    }

    public void getSelectedPackages() {
        for(packagewrapper1 pkgwrapper : packages){
            if(pkgwrapper.selected == true){
                if(AccountSelectedSet.contains(pkgwrapper.pkgs.Id)) {
                } else {
                    AccountSelectedSet.add(pkgwrapper.pkgs.Id);
                    checkedPackages.add(pkgwrapper.pkgs);
                }
            }
        }
    }

    public PageReference cancel() {
        PageReference opportunityPage = new PageReference('/'+opprid);
        opportunityPage.setRedirect(true);
        return opportunityPage;
    }

    public PageReference save() {
        String opprid=System.currentPageReference().getParameters().get('id');
        for(Line_Item__c chpack: [select Id, Name, Package__c,Product_Category__c,Activity__c,Cost__c,Final_Price__c,No_of_Days__c,No_Of_People__c,No_of_Male__c,No_of_Female__c,Total_Price__c,Comments__c from Line_Item__c where Opportunity__c = :opprid]){
            delete chpack;
        }
                
        for(Package__c chpack : checkedPackages){
            Line_Item__c oppline = new Line_Item__c();
            oppline.Name = chpack.Name;
            oppline.Product_Category__c= chpack.Product_Category__c;
            oppline.Activity__c = chpack.Activity__c;
            oppline.Cost__c = chpack.Cost__c;
            oppline.Final_Price__c = chpack.Final_Price__c;
            oppline.No_Of_People__c = chpack.No_Of_People__c;
            oppline.No_of_Male__c = chpack.No_of_Male__c;
            oppline.No_of_Female__c = chpack.No_of_Female__c;
            oppline.No_of_Days__c = chpack.No_of_Days__c;
            oppline.Total_Price__c= chpack.Total_Price__c;
            oppline.Comments__c = chpack.Comments__c;
            oppline.Opportunity__c = opprid;
            oppline.Package__c = chpack.Id;
            insert oppline;
        }

        PageReference opportunityPage = new PageReference('/'+opprid);
        opportunityPage .setRedirect(true);
        return opportunityPage ;
    }

    public class packagewrapper1 {
        public Package__c pkgs{get; set;}
        public Boolean selected {get; set;}
        public packagewrapper1(Package__c p) 
        { 
            pkgs = p;
            selected = false;
        }
    }
}

Test class is:
 
@isTest
private class Test_OpportunityLineItemsNew {
    static Opportunity oppor;
    static List<Line_Item__c> opporLineItem;
    static Payment_Schedule__c paySchedule;
    static List<Package__c> selectedPackages;
    static List<OpportunityLineItemsNew.packagewrapper1> packagesListNew;
    static List<OpportunityLineItemsNew.packagewrapper1> packages;
    static String opprid;

    static {
        packagesListNew = new List<OpportunityLineItemsNew.packagewrapper1>();
        packages = new List<OpportunityLineItemsNew.packagewrapper1>();
        
        oppor = new Opportunity();
        oppor.Name = 'Test Opportunity';
        oppor.Location__c = 'Nandi Hills';
        oppor.StageName = 'Lead';
        oppor.CloseDate = Date.newInstance(2016, 07, 22);
        insert oppor;
        
        opporLineItem = new List<Line_Item__c>(); 
        for(Package__c chpack: [select Id, Name, Product_Category__c,Activity__c,Cost__c,Final_Price__c,No_of_Days__c,No_Of_People__c,No_of_Male__c,No_of_Female__c,Total_Price__c,Comments__c from Package__c where Product_Category__c = 'Full Day Package']){
            Line_Item__c oppline = new Line_Item__c();
            oppline.Name = chpack.Name;
            oppline.Product_Category__c= chpack.Product_Category__c;
            oppline.Activity__c = chpack.Activity__c;
            oppline.Cost__c = chpack.Cost__c;
            oppline.Final_Price__c = chpack.Final_Price__c;
            oppline.No_Of_People__c = 2;
            oppline.No_of_Male__c = 2;
            oppline.No_of_Female__c = 0;
            oppline.No_of_Days__c = 2;
            oppline.Total_Price__c= 2000;
            oppline.Comments__c = chpack.Comments__c;
            oppline.Opportunity__c = oppor.Id;
            oppline.Package__c = chpack.Id;
            opporLineItem.add(oppline);
        }

        insert opporLineItem;

        for(Line_Item__c chpack: [select Id, Name, Package__c,Product_Category__c,Activity__c,Cost__c,Final_Price__c,No_of_Days__c,No_Of_People__c,No_of_Male__c,No_of_Female__c,Total_Price__c,Comments__c from Line_Item__c where Opportunity__c = :oppor.Id]){
            
            ApexPages.StandardSetController stdSetController = new ApexPages.StandardSetController(opporLineItem);
            stdSetController.setSelected(opporLineItem);
            OpportunityLineItemsNew con = new OpportunityLineItemsNew (stdSetController);
            con.AccountSelectedSet.add(chpack.Package__c);
        }
    }

    static testMethod List<OpportunityLineItemsNew.packagewrapper1> Test_getPackages() {
        PageReference pref = Page.AddOpportunityLineItem2;
        pref.getParameters().put('id',oppor.Id);
        Test.setCurrentPage(pref);
        Test.startTest();

        ApexPages.StandardSetController stdSetController = new ApexPages.StandardSetController(opporLineItem);
        stdSetController.setSelected(opporLineItem);
        OpportunityLineItemsNew con = new OpportunityLineItemsNew (stdSetController);
        
        Package__c pkgs = new Package__c();
        OpportunityLineItemsNew.packagewrapper1 op = new OpportunityLineItemsNew.packagewrapper1(pkgs);

        con.prdcat.Product_Category__c = null;
        con.packages = con.getPackages();
        
        Test.stopTest();
        return packages ;
    }
    
    static testMethod Void Test_getSelectedPackages() {
        PageReference pref = Page.AddOpportunityLineItem2;
        pref.getParameters().put('id',oppor.Id);
        Test.setCurrentPage(pref);
        Test.startTest();

        ApexPages.StandardSetController stdSetController = new ApexPages.StandardSetController(opporLineItem);
        stdSetController.setSelected(opporLineItem);
        OpportunityLineItemsNew con = new OpportunityLineItemsNew (stdSetController);

        con.getSelectedPackages();

        Test.stopTest();

    }
    
    static testMethod PageReference Test_filterPackagess(){
        PageReference pref = Page.AddOpportunityLineItem2;
        Test.setCurrentPage(pref);
        Test.startTest();
        
        ApexPages.StandardSetController stdSetController = new ApexPages.StandardSetController(opporLineItem);
        stdSetController.setSelected(opporLineItem);
        OpportunityLineItemsNew con = new OpportunityLineItemsNew (stdSetController);

        pref = con.filterPackagess();

        Test.stopTest();
        return pref;
    }
    
    static testMethod PageReference Test_Save(){
        PageReference pref = Page.AddOpportunityLineItem2;
        Test.setCurrentPage(pref);
        Test.startTest();

        ApexPages.StandardSetController stdSetController = new ApexPages.StandardSetController(opporLineItem);
        stdSetController.setSelected(opporLineItem);
        OpportunityLineItemsNew con = new OpportunityLineItemsNew (stdSetController);

        //getCheckecPackages
        pref = con.save();

        Test.stopTest();
        return pref;
    }
    
    static testMethod PageReference Test_Cancel(){
        PageReference pref = Page.AddOpportunityLineItem2;
        Test.setCurrentPage(pref);
        Test.startTest();

        ApexPages.StandardSetController stdSetController = new ApexPages.StandardSetController(opporLineItem);
        stdSetController.setSelected(opporLineItem);
        OpportunityLineItemsNew con = new OpportunityLineItemsNew (stdSetController);
        pref = con.cancel();
        Test.stopTest();
        return pref;
    }

    static testMethod void TestgetSelectedPackages(){
        PageReference pref = Page.AddOpportunityLineItem2;
        Test.setCurrentPage(pref);
        Test.startTest();

        ApexPages.StandardSetController stdSetController = new ApexPages.StandardSetController(opporLineItem);
        stdSetController.setSelected(opporLineItem);
        OpportunityLineItemsNew con = new OpportunityLineItemsNew (stdSetController);

        con.getSelectedPackages();

        Test.stopTest();
    }
}

 
Hi everyone,
In my custom vf page i have create a picklist with 3 different values,when a value is selected from picklist then related dependent fields are showing. some fields are comman for picklist values. I want to clear the values in those common fields when picklist value is changed.
 Can anyone help me over here.

Regards,
mac.

Hello All,
I am trying to create a trigger in the Process Builder to Update a custom "Risks Updated by" field and Risk Updated Date field to the current user and today () if any 1 of 3 Account fields were changed.

I tested it out and I received an error via email that says this: Error Occurred: UPDATE --- UPDATE FAILED --- ERRORS : (MALFORMED_ID) Risks Updated By: id value of incorrect type: Julia Rodriguez, 
I used this as the formula:  $User.FirstName + " "+ " " +$User.LastName

Can anyone help me fix this so I do not get this error?

Thank you for your time!

Julia

Hi,

When I release Workflow Field Updates, the following error was occured.

error message:
The queue: myQueue1 has not been setup to support the object: Case. This must be configured in the setup UI Queues editor.

Is there someone have been found like this error?

Thanks

Regards,
LinThaw.
I get the error Invalid type: Approval.ProcessSubmitRequest when I have the statement 
Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();

which I need to submit a request.  I don't understand why.  Even Salesforces own documentation show this way to create the object.  Any help?

 
I have been tasked with setting up two customer graphs in every one of our location in salesforce.  One, that will instantly show how many cases are open, and what status they are in.  THis one I did fairly easily with a report that I added to the page layout.

The other ask though is for a graph that will display the overall 'health' of the location.  Basically what they need with this is a simple indicator that will go from red/yellow/green along with a percentage marker that shows how will the location is running.  Behind the scenes, this indicator will be based off of three seperate factors:  How many times the location has been marked as 'down', what the average open to close time is on cases, and how many cases.  All of these factors for now are going to be pulled from the current week.

I'm not sure how to do this.   I don't think it would be possible to do it with just a simple report, but I'm not sure what other tools that salesforce has that could do something like this.  Does anyone have any ideas?  Anything would be greatly appreciated!

Thank you!
Hello,

I need to take programmatically the currently logged user via apex source code to change the permissions of that user.
Here is my code:
public with sharing class UnlockRecordDuringApprovalController {
 
Opportunity objOpportunity;
 
public UnlockRecordDuringApprovalController(ApexPages.StandardController controller) { 
objOpportunity = (Opportunity)controller.getRecord(); 
}
 
public void processRecord() {
 
}
 
}


Please advise or give example(s) how this can be achieved in Salesforce?
Thank you
which tool is better in salesforce Apex Data Loader or ETL tool Informatica ? How to get hands on on Informatica ?

Thanks
 
Hi friends

why  we use Bulk API and metadata api? Please explain with real example.
How to create visual force page just to display data get from my local database (MSSQL) and upon clicking on a button will update back the data into my local database (MSSQL). I do not want to store any data in Salesforce. Will it be possible?
Hi all,

I would like to integrate Quickbooks (External App) with the salesforce using the salesforce CANVAS feature. I highly appreicate for all your responses.

Thank you.
Hi, I just wrote the below trigger but its showing the error, Can anyone plz help me out where it went wrong. thanks
Custom object : True_Promo__c, Custom field name : TrueYou_Privilege1_Code__c
Standaard Object : Lead, Custom Field Name : TrueYou_Privilege_Code__c
I want the "TrueYou_Privilege1_Code__c" input from the custo object should auto populate into teh lead object field.

ERROR showing : Compile Error : Invalid field lead for sObject True_Promos__c at line 18 column 13

trigger SetLeadOnTruePromo on True_Promos__c (before update, before insert) {
    Set<string> TruePrivileges = new Set<string>();

    for (True_Promos__c  checkTPrivilege : Trigger.new) {
    TruePrivileges.add(checkTPrivilege.TrueYou_Privilege1_Code__c);
    }

    List<Lead> LeadList = [SELECT id, TrueYou_Privilege_Code__c FROM Lead WHERE TrueYou_Privilege_Code__c IN :TruePrivileges];

    Map<string, Lead> PrivilegeCodeToLeadMap = new Map<string, Lead>();

    for (Lead c : LeadList) {
        PrivilegeCodeToLeadMap.put(c.TrueYou_Privilege_Code__c, c);
    }

    for (True_Promos__c  p : Trigger.new) {
        if (p.TrueYou_Privilege1_Code__c != null) {
            p.Lead = PrivilegeCodeToLeadMap.get(p.TrueYou_Privilege_Code__c).id;
        }
        else {
            p.Lead = null;
        }
    }
I'm very new to Salesforce and have written a class to export an opportunity to csv. It now exports correctly but when trying to write a test class I'm getting the above error when trying to reference the method within my class. I'm also not sure what to write for the assert method. As I'm new to this I'm really lost, any help would be appreciated.

exportCSV class:

public with sharing class exportCSV {
    public string header{get;set;}
    public String currentRecordId {get;set;}
    public String rId {get;set;}
    public List<Opportunity> AllOpenOpportunities {get; private set;} 
    public exportCSV() {
        header = 'Acc_Ref__c,Purchase_Order_Number1__c,Position__c,Total_Hours_Required__c,Shift_Start_Date__c,Shift_End_Date__c,Number_of_Shifts__c,Hours_per_Shift__c,Shift_Time__c,Pay_Code__c,Opportunity_Unique_Reference__c\r';
        rId  = ApexPages.currentPage().getHeaders().get('Referer');
        Id currentRecordId = rId.right(15);
        AllOpenOpportunities = [SELECT id, Name, Acc_Ref__c, Purchase_Order_Number1__c, Position__c, Total_Hours_Required__c, Shift_Start_Date__c, Shift_End_Date__c,Number_of_Shifts__c,Hours_per_Shift__c,Shift_Time__c,Pay_Code__c, Opportunity_Unique_Reference__c
                            FROM Opportunity 
                            WHERE id =: currentRecordId];
    }
}


Test class so far:

@isTest                    
public class TestClassOne {

    public static testMethod void testMethodOne() {
        // Create Account Data
        Account acc = new Account(Name='TestAcc');
        insert acc;

        // Create Opportunity Data
        Opportunity opp = new Opportunity(Name='Test Opp', AccountId=acc.Id);
        insert opp;
        system.currentPageReference().getParameters().put('currentRecordId', opp.Id);
        exportCSV conObj = new exportCSV();
        Test.startTest();
        // Call Methods of the class
        conObj.exportCSV();
        Test.stopTest();
        // Write assert statements
    }   
}

 
Need help in creating validation rule, where a case can be closed as duplicate, if the Associated case field is not blank and the associated case status is not equal to closed
Here's the code:
        if (UtilQuote.isUpdate) {
            //验证产品是否有效
            for (Quote qu : Quotes)
            {
                if (trigger.newMap.get(qu.Id).Cnt_of_Quote_line__c >= trigger.oldMap.get(qu.Id).Cnt_of_Quote_line__c )
                {
                    List<QuoteLineItem> inActiveProLst = [Select Id,PricebookEntry.Product2.Id,PricebookEntry.Product2.Name From QuoteLineItem where QuoteId IN:quotes and PricebookEntry.Product2.IsActive = false]; 
                    for (QuoteLineItem qli : inActiveProLst ) {
                        trigger.new[0].addError('该报价单有无效的产品:' + qli.PricebookEntry.Product2.Name + ',请重新选择产品!');
                        break;
                    }
                } 
            }

how can I exclude user in these two profiles?
$User.ProfileId <>"00e90000000qoiZ"
$User.ProfileId <>"00e90000000pV2l"

it's quite easy in validation rules but I don't know how to change the code, would somebody help?

Thank you very much in Advance!!!
User-added image




i have error ...........what are steps follow any one tell me answer plz......
I want to count how many Contact has value under description field using for loop. Similarly if Contact object has custom field then how to count those field which has some value
SELECT COUNT() Amo__c FROM Contact WHERE Description != null
The above query is not working
I have a http request (to an external system) which is returning a valid json response when I put it in browser, but when I try to use the http request from code, it doesn't work.

It further looks that when it returns, its actually taking to the salesforce Remote Authorization page, thus causing a redirect.

Is there are way to proceed further when this Redirect Authorization page is coming in apex or what do I need to pass in the http request (I added the Header Authorization : 'OAuth' + UserSessionid in the request from salesforce to the api.

Debug statement of Response.getBody();
==
if (this.SfdcApp && this.SfdcApp.projectOneNavigator) { SfdcApp.projectOneNavigator.handleRedirect('https://test.salesforce.com/?ec=302&startURL=%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3Dsdjfnsdjkfbjsdfbsdbfsdjhbfhsdbf'); }  else
if (window.location.replace){ 
window.location.replace('https://test.salesforce.com/?ec=302&startURL=%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3D.............
==
is this Code is right??

trigger createAssetonClosedWon on Opportunity (after insert, after update) {
    for(opportunity o:Trigger.New) {
        if(o.iswon==true && o.hasOpportunitylineitem==true){
            string opptyId= o.Id;
            Opportunitylineitem[] OLI=[Select Quantity,UnitPrice,PricebookEntry.Product2Id, PricebookEntry.Product2.Name, Description from opportunitylineitem where opportunityId=:opptyId];
            asset[] ast= New Asset[]{};
                asset a= new asset();
            for(opportunitylineitem ol:OLI){
                a= new asset();
                a.AccountId=a.AccountID;
                a.Quantity=ol.quantity;
                
                a.Product2Id=ol.PricebookEntry.Product2Id;
                a.price=ol.UnitPrice;
                a.Description=ol.Description;
                a.name=ol.PricebookEntry.Product2.Name;
                ast.add(a);
                
                
            }
            
            insert ast;
            
            
        }
    }
}
 error 
Apex trigger myruchika.createAssetonClosedWon caused an unexpected exception, contact your administrator: myruchika.createAssetonClosedWon: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: AccountId, ContactId (asset must have account and/or contact parent(s)): [AccountId, ContactId]: Trigger.myruchika.createAssetonClosedWon: line 22, column 1 
  
I'm trying to build a table using Vf combining data from two custom objects. The table will need to report on a specific record and also use formulas in the code to calculate output data.

I have some code but not sure if i'm even heading the right direction.  Any help would be greatly appreciated.
<apex:page  standardController="Professional_Service_Estimate__c" extensions="summary_table_ext">  
    <apex:form id="formId">
        
        <apex:pageBlock>
        	<apex:inputfield value="{!Professional_Service_Estimate__c.Name}"/>
		</apex:pageBlock>  
            
       <apex:pageBlock title="Estimated Professional Services Fees">
            <apex:pageBlockTable value="{!estimate_list}" var="el">
                <apex:column headerValue="Cost Breakdown - EDRC - AE %">
                    <apex:outputText value="{!el.Current_Fee__c} + {!el.What_s_Added_b_c_of_salary_escalation__c} + {!el.Added_b_c_of_Construction_Escalation_ECC__c}"  />
                </apex:column>
                <apex:column headerValue="State">
                    <apex:outputField value="{!st.State__c}" />
                </apex:column>
                <apex:column headerValue="Building Type">
                    <apex:outputField value="{!st.Building_Type__c}" />
                </apex:column>
        	</apex:pageBlockTable>
        </apex:pageBlock>
        
        <apex:pageBlock title="Project Details">
            <apex:pageBlockTable value="{!estimate_list}" var="st">
                <apex:column headerValue="City">
                    <apex:outputField value="{!st.City__c}" />
                </apex:column>
                <apex:column headerValue="State">
                    <apex:outputField value="{!st.State__c}" />
                </apex:column>
                <apex:column headerValue="Building Type">
                    <apex:outputField value="{!st.Building_Type__c}" />
                </apex:column>

                <apex:column headerValue="CECC">
                    <apex:outputField value="{!st.CECC__c}" />
                </apex:column>
                <apex:column headerValue="ECC">
                    <apex:outputField value="{!st.ECC__c}" />
                </apex:column>
                <apex:column headerValue="Estimated Total GSF">
                    <apex:outputField value="{!st.Estimated_Total_GSF__c}" />
                </apex:column>
                
                <apex:column headerValue="Anticipated Date of Design Award">
                    <apex:outputField value="{!st.Anticipated_Date_of_Design_Award__c}" />
                </apex:column>
                <apex:column headerValue="Anticipated Start Date of Construction">
                    <apex:outputField value="{!st.Anticipated_Start_Date_of_Construction__c}" />
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

VF:
public class summary_table_ext {

    public List<Professional_Service_Estimate__c> service_list {get; set;}
    public List<Professional_Service_Estimate_List__c> estimate_list {get; set;}

    public summary_table_ext(ApexPages.StandardController controller) {
        
        service_list = [SELECT Id, City__c, State__c, ECC__c, CECC__c, Estimated_Total_GSF__c, Anticipated_Date_of_Design_Award__c, Anticipated_Start_Date_of_Construction__c,Time_until_Midpoint_of_Design_years__c,
                        Building_Type__c
       
                        FROM Professional_Service_Estimate__c];

        estimate_list = [SELECT Id, Added_b_c_of_Construction_Escalation_ECC__c, What_s_Added_b_c_of_salary_escalation__c, Current_Fee__c,
                     	EDRC_EMIC_Type__c, Escalated_by_Salary__c, Future_Fee_ECC__c, Percentage_ECC__c, Percentage__c, Professional_Service_Estimate__c,
                     	Type__c
                        FROM Professional_Service_Estimate_List__c];
    }
}