• Ratan
  • NEWBIE
  • 379 Points
  • Member since 2014


  • Chatter
    Feed
  • 12
    Best Answers
  • 0
    Likes Received
  • 4
    Likes Given
  • 1
    Questions
  • 108
    Replies
I am trying to create objects and fields dynamically using apex code, But I'm getting the error "Method does not exist or incorrect signature: void createService() from the type anon". I have deployed the metadataservice class and related classes in my Org. I try to create an object using below code:



 MetadataService.MetadataPort service = createService();
        MetadataService.CustomObject customObject = new MetadataService.CustomObject();
        customObject.fullName = 'Test__c';
        customObject.label = 'Test';
        customObject.pluralLabel = 'Tests';
        customObject.nameField = new MetadataService.CustomField();
        customObject.nameField.type_x = 'Text';
        customObject.nameField.label = 'Test Record';
        customObject.deploymentStatus = 'Deployed';
        customObject.sharingModel = 'ReadWrite';
        List<MetadataService.SaveResult> results =
            service.createMetadata(
                new MetadataService.Metadata[] { customObject });
        handleSaveResults(results[0]);

I have executed the above code and I got the error:  I am getting the error because I don't have Createservice() method in my metadataservice class. Can anyone help me how to fix this?

Hi All,

I am working on a requirement where the child item is created based on the id of the parent and we are using a combination of sfdc standard and vf pages to accomplish it. But, there are places where we have this recent items panel that contains a new button which will take us to the record creation vf page which is wrong as the parent record id will be null.
User-added image
That's why i want the recent items panel to be gone or the new button to be removed.
Please let me know how to achieve this?
Also, if it isn't possible to remove from my end , Is it possible for salesforce tech support to disable certain things only for my org?

Hi All

I am currently working on an implementation of a calendar view in a Visualforce page. Basic idea is to display a schedule on the calendar based on date fields in custom objects. From some searching, I came across this article: http://www.codebycody.com/2013/06/create-calendar-view-in-salesforcecom.html

I tried to follow the code in the working example, but the calendar does not display in the page. Below is the screenshot of the page: 
User-added image

Glady appreciate if someone can guide me through this issue and how best to implement this feature. 
Hey Team, 

I need to implement the chatter on vf with groups and other standard features of chatter. I am using <chatter:feed entityId='{!}' />.

I am getting chatter feed but am not getting the icons which are on left side like groups.

Kindly help me 
Can anyone help me with test code for the following trigger?

trigger addAccount on Lead (before Insert, before Update)
{
 
 List<string> companies=new list<string>();
 
  For (lead l:trigger.new){
    companies.add(l.company);
  }
 
  List<Account> leadAccountIds=[Select Id, OwnerId, Name FROM Account WHERE Name IN: companies];
 
   Map<String, Id> acctNameId=new Map<String, Id>();
   Map<String, Id> acctNameOwner=new Map<String, Id>();
 
  For (Account a:leadAccountIds){
    acctNameId.put(a.name,a.Id);
    acctNameOwner.put(a.name,a.ownerId);
  }
 
  For (Lead l2:trigger.new){
    if(acctNameId.containsKey(l2.company)){
      l2.Account_Name__c=acctNameId.get(l2.company);
      l2.ownerId=acctNameOwner.get(l2.company);
    }
  }
}

Thank you!!

Shannon
Can any one please explain, why we use "Static Resource" in VF Markup to display images and to link other elements like CSS and JS files. Why we do not place these components in "Document" folder and use it on a VF page. What all advantages are there if we use Static Resource.

Thanks in advance..!!

Regards,
Rajneesh
Something like TEXT(Implementation_Stage__c) = ANY("X", "Y", "Z").

Implementation_Stage__c is a picklist. If it's value is X or Y or Z. Do something.

hi i written this query then showing error. please help.

this is working well. 
list<product2> pro=[select id,name,(select id from attachments) from product2   ];


But here i want to show only products which product records has attachments.  But getting error. 
list<product2> pro=[select id,name,(select id from attachments) from product2 where id in (SELECT ParentId FROM Attachment)  ];

 
Code:
public class ContactAndLeadSearch{
    public static List<List<SObject>> searchContactsAndLeads(String name){
       return [FIND :name IN Name RETURNING Leads(Name),Contact(FirstName,LastName)];
    }
}
I am just trying to return Lead and Contact object where name contains the string passed to this method.
Hi All

Below is the code for my trigger and test class but the code coverage showing 0 for me. Please let me know where I am going wrong

Trigger


trigger stageChangetest on Opportunity (before update) {
    List<string> accountNames = new List<string>();
    for (Opportunity o : trigger.new) {
        if(trigger.isupdate && o.Stagename == '7. Closed/Won'){
         accountNames.add(o.AccountId);
        }
    }
    AggregateResult[] results = [select Account.Id, MAX(cas_LastConnect__c) from Contact where Account.Id in :accountNames and cas_LastConnect__c != null group by Account.Id ];
    Map<String, Datetime> account_connectDate = new Map<String, Datetime>();
    for(AggregateResult ar : results){
        account_connectDate.put(String.valueof( ar.get('Id')), Datetime.valueof( ar.get('expr0')));
    }
    
    Datetime today = Date.today().addMonths(-6);
    List<Opportunity> opportunities = new List<Opportunity>();
    for (Opportunity o : trigger.new) {
        if(trigger.isupdate && o.Stagename == '7. Closed/Won' && account_connectDate.containsKey(o.AccountId)){
            Datetime lastConnectDate = account_connectDate.get(o.AccountId);
            system.debug(logginglevel.info,today);
            system.debug(logginglevel.info,lastConnectDate);
            if(lastConnectDate > today){
                o.ConnectAndSell_bookings_contribution__c = o.Amount;
            }
        }
    }
}

Test Class


@isTest(seeAllData=false)
private class cas_ClosedAmountTest {
    /** Test with an existing opportunity **/
    static testMethod void testWithExistingContact() {
    //init();
    Test.startTest();
    Account acc = new Account();
    acc.Name = 'test account';
    acc.Phone = '123214';
    acc.Type = 'Customer';   
    
    insert acc;
    //Account acc = [select Account.Id from Account where Name='Kuliza'];    
    Opportunity opp = new Opportunity( Name = 'test opportunity',
                              AccountId = acc.Id,
                              StageName = 'Negotiations',
                              CloseDate = System.today(),
                              Type = 'New Business - Add',
                              Amount = 5558);
    insert opp;
    opp.StageName = '7. Closed/Won';
    update opp;
    
    AggregateResult[] results = [select MAX(cas_LastConnect__c) from Contact where Account.Id = :acc.Id and cas_LastConnect__c != null ];
    Map<String, Datetime> account_connectDate = new Map<String, Datetime>();
    for(AggregateResult ar : results){
        account_connectDate.put(String.valueof( ar.get('Id')), Datetime.valueof( ar.get('expr0')));
    }
        Datetime today = Date.today().addMonths(-6);
        Double casContribution = null;
        if(account_connectDate.containsKey(opp.AccountId)){
            Datetime lastConnectDate = account_connectDate.get(opp.AccountId);
            if(lastConnectDate > today){
                casContribution = opp.Amount;
            }
        }
    // Verification
    System.assertEquals(opp.ConnectAndSell_bookings_contribution__c, casContribution);
    Test.stopTest();
    }
}
 
how can i remove a value from a list without refering its index.??? i have 2 multiselectPiclists on my VF page, so the value selected from first piclist should be removed from second picklist. how am i supposed to do it.?
Hello Every one,

When i click on a button in visualforce page, it has to capture the screenshot of the page and it has to send an email to some user. How can i achieve this?? I tried in different ways but strucked in some protions. Will you share your idea or any solution for this.

Thanks in advance !!
  • March 31, 2016
  • Like
  • 0
I want to display opportunities of selected Account records in another table on same page using wrapper class.

Thanks
I am trying to create objects and fields dynamically using apex code, But I'm getting the error "Method does not exist or incorrect signature: void createService() from the type anon". I have deployed the metadataservice class and related classes in my Org. I try to create an object using below code:



 MetadataService.MetadataPort service = createService();
        MetadataService.CustomObject customObject = new MetadataService.CustomObject();
        customObject.fullName = 'Test__c';
        customObject.label = 'Test';
        customObject.pluralLabel = 'Tests';
        customObject.nameField = new MetadataService.CustomField();
        customObject.nameField.type_x = 'Text';
        customObject.nameField.label = 'Test Record';
        customObject.deploymentStatus = 'Deployed';
        customObject.sharingModel = 'ReadWrite';
        List<MetadataService.SaveResult> results =
            service.createMetadata(
                new MetadataService.Metadata[] { customObject });
        handleSaveResults(results[0]);

I have executed the above code and I got the error:  I am getting the error because I don't have Createservice() method in my metadataservice class. Can anyone help me how to fix this?
Hi,

I am trying to write a trigger that will call the class whenever an update is made to the record.  I believe I am doing this wrong and I have many problems.  How do I write this trigger?

My class: 
public class DrivingDistance1 {
    public static void m1() {
geopointe.API.DistanceService ds = new geopointe.API.DistanceService();
List<Account> accList = [SELECT id, 
                         distance1__c, 
                         UCO_Service_Provider__r.Geopointe_Geocode__r.geopointe__Latitude__c, 
                         UCO_Service_Provider__r.Geopointe_Geocode__r.geopointe__Longitude__c, 
                         geopointe__Geocode__r.geopointe__Latitude__c, 
                         geopointe__Geocode__r.geopointe__Longitude__c FROM Account LIMIT 1];
List<Account> origins = new List<Account>();
List<Account> destinations = new List<Account>();
    
    for(Integer i = 0; i < accList.size(); i++){
        if(Math.mod(i,2) == 0) {
            origins.add(accList.get(i));
        } else {
            destinations.add(accList.get(i));
        }
    }
    for(Integer i = 0; i < origins.size(); i++){
        ds.add((Double)origins.get(i).geopointe__Geocode__r.geopointe__Latitude__c,
              (Double)origins.get(i).geopointe__Geocode__r.geopointe__Longitude__c,
              (Double)destinations.get(i).UCO_Service_Provider__r.Geopointe_Geocode__r.geopointe__Latitude__c,
              (Double)destinations.get(i).UCO_Service_Provider__r.Geopointe_Geocode__r.geopointe__Longitude__c);
    }
    for(Integer i = 0; i < origins.size(); i++){
        Double distance = ds.getDistanceAtIndex(i);
        origins.get(i).distance1__c = distance;
        destinations.get(i).distance1__c = distance;
    }
    update accList;
    }
}

My trigger:
trigger DrivingDistanceTrigger on Account (after update) {
  geopointe__Geocode__r.geopointe__Latitude__c[] = Trigger.new;
    DrivingDistance1.m1(distance);
}
Hi All,

I'm a novice to salesforce and facing some technical hiccups while implementing the custom button javascript onClick section. My problem statement is-

1. I have created a custom button for lead SO.
2. I will add this custom button on the Lead page layout (New).
3. When user creates a new Lead and click on this custom button, I would like to validate the email address what user has entered on the lead page.
4. I need to know in Javascript as to how to pass the sObject to the Apex- Webservice method, so that I can retrieve the email address. Also post verification I can update the same on the lead page. Please mind that the new record is still not saved.
5. Post validation user can click on SAVE button on Lead page and save the record.

Please note that this is a non-override approach.

Any help please?
Hi,

I want to retrive in SOQL account record type from child object opportunity.

how can i write the query ?
Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: []
Hello,

Can i change limit of visualforce page?

Thank you
Hi,

I have some records with checkboxes in visualforces page. I am using wrapper class. I need to add the selected record(checkbox) to another table. When I click on checkbox then all records are getting added to the table again and again rather than only the one whick I check.

Visualforce Page:
 
<apex:page controller="OpportunityLineItems" >
    <apex:form >
        <apex:pageBlock title="Selected Packages">
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
                <apex:pageblockTable value="{!checkedPackages}" var="pck" id="Selected_PBS"  >
                    <apex:column headerValue="">
                        Remove
                    </apex:column>
                    <apex:column headerValue="Product Name" value="{!pck.Name}" width="50" />
                    <apex:column headerValue="Product Category" value="{!pck.Product_Category__c}" width="50" />
                    <apex:column headerValue="Activity" width="50">
                        <apex:inputField value="{!pck.Activity__c}"/>
                    </apex:column>
                    <apex:column headerValue="Price" value="{!pck.Cost__c}" width="50"/>
                    <apex:column headerValue="Final Price" width="50">
                        <apex:inputField value="{!pck.Final_Price__c}"/>
                    </apex:column>
                    <apex:column headerValue="No of Days" width="50">
                        <apex:inputField value="{!pck.No_of_Days__c}"/>
                    </apex:column>
                    <apex:column headerValue="No Of People" width="50">
                        <apex:inputField value="{!pck.No_Of_People__c}"/>
                    </apex:column>
                    <apex:column headerValue="No Of Male" width="50">
                        <apex:inputField value="{!pck.No_of_Male__c}"/>
                    </apex:column>
                    <apex:column headerValue="No Of Female" width="50">
                        <apex:inputField value="{!pck.No_of_Female__c}"/>
                    </apex:column>
                    <apex:column headerValue="Total Price" width="50">
                        <apex:inputField value="{!pck.Total_Price__c}"/>
                    </apex:column>
                    <apex:column headerValue="Comments" width="50">
                        <apex:inputField value="{!pck.Comments__c}"/>
                    </apex:column>
                </apex:pageblockTable>
        </apex:pageBlock>
        <apex:pageBlock title="Search for Packages">
            <apex:outputLabel >Packages Category</apex:outputLabel>
            <apex:inputField value="{!prdcat.Product_Category__c}" >
                <apex:actionSupport event="onchange" rerender="packagesList" action="{!filterPackagess}"/>
            </apex:inputField>
                <apex:pageblockTable value="{!packages}" var="a" id="packagesList" >
                    <apex:column headerValue="Select" width="60">
                        <apex:inputCheckbox value="{!a.selected}" id="checkedone" >
                            <apex:actionSupport event="onclick" action="{!getSelectedPackages}" rerender="Selected_PBS"/>
                        </apex:inputCheckbox>
                    </apex:column>
                    <apex:column value="{!a.pkgs.Name}"/>
                    <apex:column value="{!a.pkgs.Product_Category__c}"/>
                    <apex:column value="{!a.pkgs.Cost__c}"/>
                    <apex:column value="{!a.pkgs.Stay__c}"/>
                    <apex:column value="{!a.pkgs.Activity__c}"/>
                    <apex:column value="{!a.pkgs.Description__c}"/>
                </apex:pageblocktable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Wrapper class:
public class OpportunityLineItems {

    List<Package__c> selectedPackages = new List<Package__c>();
    public Package__c prdcat{get;set;}
	List<packagewrapper1> packagesListNew = new List<packagewrapper1>();
    public OpportunityLineItems(){
        prdcat = new Package__c();
    }

    public  List<packagewrapper1> getPackages(){
        packagesListNew.clear();
        filteredList = new List<Package__c>();
        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 ){
            packagesListNew.add(new packagewrapper1(a));
        }
        return packagesListNew;
    }
    
    List<Package__c> filteredList = new List<Package__c>();
    List<packagewrapper1> packages = new List<packagewrapper1>();
    public  PageReference  filterPackagess(){
        packages.clear();
        return null;
    }

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

    public List<Package__c> GetCheckedPackages() {
        if(selectedPackages.size()>0)
        return selectedPackages;
        else
        return null;
    }

    public PageReference getSelectedPackages() {
        selectedPackages.clear();
        for(packagewrapper1 pkgwrapper : packagesListNew)
        if(pkgwrapper.selected == true)
        selectedPackages.add(pkgwrapper.pkgs);
		return null;
    }

    public PageReference cancel() {
        return null;
    }

    public PageReference save() {
        return null;
    }

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


Can anyone help me.

Thanks,
Rohitash
 
Hi to all,
          I am new to salesforce I have one scenario,when I open the record automatically it sends the email to the owner.How can we achieve this scenario.Please help.

Tanks in advance
Hi All,
I have to get list of sObjects which is customizable means the list of object on which we can create fields.
Thanks in Advance.

Hi All,

I am working on a requirement where the child item is created based on the id of the parent and we are using a combination of sfdc standard and vf pages to accomplish it. But, there are places where we have this recent items panel that contains a new button which will take us to the record creation vf page which is wrong as the parent record id will be null.
User-added image
That's why i want the recent items panel to be gone or the new button to be removed.
Please let me know how to achieve this?
Also, if it isn't possible to remove from my end , Is it possible for salesforce tech support to disable certain things only for my org?

Hi,

I have exposed a custom REST service through Apex code. I have given the following curl command to get the data from the API and it works fine if passed the session id in the header.

curl https://na30.salesforce.com/services/apexrest/testservice -H 'Authorization: Bearer 00D36000000wE02!ARAAQNag09f5_h7z8_ArS_JFo6f1o9Ag4C7y201UJDlyP66MSE1YrL7brsqS5CmCOO5' -H 'X-PrettyPrint:1'

But when I tried to use the Basic HTTP authentication it gives me below error. I have encoded the username and the password with base64

curl https://na30.salesforce.com/services/apexrest/testservice -H 'Authorization: Basic <username:password>'

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

What I'm doing wrong here. Do I need to make any change in the back end code as well?
My territory assigment rule fire when ever i save the record from UI, but i would like to automate it even if i save the record from back end 
how to do it please advise
Hello All,
I have completed this challenge.

1-For this first you need to create a helper formula field(type-percent) 
Percent Completed :
(DATEVALUE( CreatedDate ) - CloseDate )/100


2- Then you need to create the actual formula field (type- text) by using the helper formula field.
Opportunity Progress :

IF( Percent_Completed__c <=25,"Early", 
IF(Percent_Completed__c <=75,"Middle", 
"Late"))

Thanks,
Nida



 

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.