• sfdev179
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 2
    Replies

Hello

 

I have two fields:

1.Transaction Number of Car(type autonumber)

2.Sale Price of car(type number)

 

I want to create a report to display the Percentage of cars sold to total cars.

If the sales price field contains a value,it means car was sold.Otherwise if null or 0,the car was not sold.

The total number of cars can be obtained by record count of transaction numbers of car.

But how to obtain the number of cars sold? and then calculate the required percentage?

 

Any help much appreciated.

Thanks

I want to assign activities related list From lead to Accounts without converting the leads.The trigger runs when the Value in a custom field 'auction access id' matches the value of the same field on acount object.The part of the code that reassigns activities is as follows:

 

for(Account actts : mapOfAccounts.values()){
if(ActivityHistoryMap.containsKey(actts.auction_access_Id__c)){

for(ActivityHistory ah :ActivityHistoryMap.get(actts.auction_access_Id__c)){


ah.WhoID = null ;
ah.WhatID = actts.Id ;


}
}

 

 

however i get this error: : Compile Error: Field is not writeable: ActivityHistory.WhoId

 

please help on how to reassign activities using this code or another that would do the job.

Thanks

Hello

 

Im new to apex and I have written a code to create a contact on account creation and its updation when account is updated.

the code is as follows:

trigger CreateAccountContact on Account (after insert,after update){

    if(Trigger.isInsert){
    
        List<Contact> ct = new List <Contact>();
        
        for(Account acc : trigger.new){

        Contact c = new Contact(LastName = acc.name,
                        AccountId=acc.id,
                        Fax=acc.Fax,
                        Phone=acc.Phone,
                        Email=acc.Email__c);

        ct.add(c);
        
        }
        
        if(!ct.isEmpty())
            {insert ct; }
    }
    else{
    
    Set<Id> acctIds = new Set<Id>();
    List<Contact> cntsload = new List<Contact>();
    //Map<Id, Account> contactmap = new Map<Id, Account>{};
    
    for(Account acc : trigger.new){

              acctIds.add(acc.id);

              //contactmap.put(acc.id, acc);

       }
      cntsload = [select AccountId,Name
                           from Contact
                           where AccountId in :acctIds];
       
     for (Contact cnt :cntsload ){
                           
                           
                        cnt.LastName=Trigger.newMap.get(cnt.AccountId).Name;
                        cnt.Fax=Trigger.newMap.get(cnt.AccountId).Fax;
                        cnt.Phone=Trigger.newMap.get(cnt.AccountId).Phone;
                        cnt.Email=Trigger.newMap.get(cnt.AccountId).Email__c;
     }
                      if(!cntsload.isEmpty()){
            update cntsload;
                           
                           }
                           }
    
    }

 

 

I have written a test class but it throws an exception of:System has no rows for assignment to Sobject.

 

@isTest

public class TestCreateAccountContact{

static testmethod void TestgetAgentInfoCon()

   {
   Account testacc=new Account();
    testacc.name='tstacc';
    testacc.Email__c='tst@aol.com';
    testacc.Customer_No__c='123';
    insert testacc;
    
    Account act=[select id,name,email__c from Account where name=:'tstacc'];
    //Agent__c dumAgnt=[Select id,Name from Agent__c where Name='Dummy Agent'];
    
    Test.startTest();
    Contact ct=[select id,LastName,email,accountID from contact where accountID=:act.id];
    

    System.assertEquals('tstacc',ct.LastName);
    System.AssertEquals('tst@aol.com',ct.Email);
   
Test.stopTest();
    
    
    }}

 

Please suggest changes to either of the codes to resolve error.

Thanks!

I want to mass upload images of a contact in salesforce using scripted data loader if possible.The image of the contact has to be displayed on to the contact record.How should I go about it?

If I create a rich text area field the image when normally uploaded is displayed.But since im mass importing images,i need to find a way to do that using scripted data loader.

 

Any help would be appreciated.

 

Thanks

I am a beginner and I have to write an apex class that allows only one opportunity product to be added to any opportunity and then invoke it using trigger.It sounds simple,but I cant seem to develop the logic.

 

Any sample code or any help would be much appreciated.

I want to mass upload images of a contact in salesforce using scripted data loader if possible.The image of the contact has to be displayed on to the contact record.How should I go about it?

If I create a rich text area field the image when normally uploaded is displayed.But since im mass importing images,i need to find a way to do that using scripted data loader.

 

Any help would be appreciated.

 

Thanks

I am a beginner and I have to write an apex class that allows only one opportunity product to be added to any opportunity and then invoke it using trigger.It sounds simple,but I cant seem to develop the logic.

 

Any sample code or any help would be much appreciated.