• salmanmanekia
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 11
    Replies

Hi,

 

I have two objects fromUpdated and toBeUpdated. Both the objects have two fields aField and bField. I have to write a code such that when a new record is inserted in toBeUpdated . It checks if the record has been already there previously. The key which is cheked is aField and if the aField is a match between two records then it just updates the another field bField without creating a new record for the toBeUpated object.

 

After this operation i also have to delete all the objects from the fromUpdate object.

 

I know query and delete() would provide this functionality but how to write a SOQL statement for this functionality is what i cannot figure it out.

 

Any help would be appreciated..

 

Thanks

 

 

Hi,

 

Can someone have a look at it. Below is the code and the error

 

global void execute(
        Database.BatchableContext BC,
        List<sObject> listObj){
            
            list <Account> inAcc = new list<Account>();
            for (sObject lo : listObj){
                Unprocessed_Agreement__c temp = (Unprocessed_Agreement__c)lo;
                inAcc.add(processor.processAccountRecord(temp));
                }
            insert(inAcc); // This line throws the error
            }

 

 

the processor class looks something like this

 

global class CreateAndModifyProcessor {
    global Account processAccountRecord( Unprocessed_Agreement__c temp){
        Account tempAcc = new Account();
        tempAcc.Begining__c = temp.Begining__c;
        tempAcc.Agreement_ID__c = temp.Agreement_ID__c;
        return tempAcc; 
    }
}

 

First error: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Name]: [Name]

 

Hi,

 

I am having this error.

First error: Insert failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: []

 

 

Tried deleting the records by using data loader but no success, also tried it by deleting the record by selecting all and deleting but the error comes

 

Cannot delete last list view. You can't delete the last list view that's Visible to all users or Visible to certain groups of users.

Hi,

I am developing an application in which i am retrieving records from an object and then want to insert (some of the fields of the) records into different objects. Below is my code in which i cannot figure it out that why my objects are not being populated and new record cannot be seen .

 

public with sharing class ScheduleBatchLauncher{
    public static String scheduleBatch(Datetime batchTime){
        CreateAndModifyScheduler batchSched = new CreateAndModifyScheduler();
        String cron = '20 25 * * * ?';
        String schedId = System.schedule('Create and Modify Batch 1', cron, batchSched);       
        return schedId;
    }

}

 

global class CreateAndModifyScheduler implements Schedulable{
   global void execute(SchedulableContext sc) {
      CreateAndModify scBatch = new CreateAndModify(); 
      database.executebatch(scBatch);
   }
}
global class CreateAndModify implements
Database.Batchable<sObject>, Database.Stateful{


    global CreateAndModifyProcessor processor;
    global CreateAndModify(){
            this.processor = new CreateAndModifyProcessor();
        }
    
    global Database.queryLocator start
        (Database.BatchableContext BC){
            return Database.getQueryLocator([Select Agreement_ID__c, Begining__c,
                                            Contact_Email__c, Contact_Name__c,
                                            Country_Code__c, Currency__c,
                                            Customer_Address__c, Customer_ID__c,
                                            Customer_Name__c,Customer_Postal_Code__c,
                                            Ending__c,Price__c FROM Unprocessed_Agreement__c]);
            }
    
    global void execute(
        Database.BatchableContext BC, 
        List<sObject> listObj){
            
            list <Account__c> inAcc = new list<Account__c>();
                       
            for (sObject lo : listObj){
                Unprocessed_Agreement__c temp = (Unprocessed_Agreement__c)lo;
                
                inAcc.add(processor.processAccountRecord(temp));    
                }
            insert(inAcc);
update(inAcc)
  } global void finish( Database.BatchableContext BC){ } }

 

global class CreateAndModifyProcessor {
    global Account__c processAccountRecord( Unprocessed_Agreement__c temp){
        Account__c tempAcc = new Account__c();
        tempAcc.Customer_Name__c = temp.Customer_Name__c;
        tempAcc.Customer_Address__c = temp.Customer_Address__c;
        tempAcc.Postal_Code__c = temp.Customer_Postal_Code__c;
        return tempAcc;
    }   
}

 

 Please if someone can have a look at it. Also, if someone wants to see my build.xml or package.xml please tell..Thank You

I have to update the record if it is already in the system. I have an Object named 'Account' and its field 'Account ID'. The condition for updating the record is that for 'Account' the key is 'Account ID'. My question is:

1 : How can i assign the 'Account ID' key to the object 'Account'. I have an idea that i have to use map function here but how to use it i do not know. My understadning was that it should be something like

Map<Account_ID__c,Account__c> map1 = new Map<Account_ID__c,Account__c>(); //ITS AN ERROR !

So whats the right way to do it.

2 : How does mapping helps me in updating record. I mean i am sure it can be done without mapping the values so how (show with code) does it makes easy to update while using the map.

 

Thanks !

Hi,

I have couple of objects, In which i have defined a few custom field and one field as a standard field.

First, i will try to explain the reason why i have defined one field as a standard field.

The couple of object which i have defined represents the record and in my app if the record is already in the system i have to update its values. For every object i have been given a key like for eg for 'Contact' object i have been given 'Contact Email ' as a key. So, i have made the contact email as the standard field while the contact name as the custome field.

 

So, my question is,

1 : that does it even matters that if the key is custom or standard field ?

2 : Why there is no API name for standard field. how can one access standard field from apex code without it having the API name?

Also last but not the least

3 : what is the significance of having a key, i mean if a field is key then in what way is it seperate from other field .

 

Thanks

 

I have two global classes. In the CreateAndModify class i have an execute functions which has a for loop which calls a processRecord method of my other class i.e CreateAndModifyProcessor. The problem is that there is a collection of list declared in my first class which i cannot access in the second class. Is there any way to do it and is it even a good ides to do it this way ?..

 

global class CreateAndModify implements
Database.Batchable<sObject>, Database.Stateful{

global void execute(
        Database.BatchableContext BC,

        List<sObject> listObj){


            list <Account__c> inAcc = new list<Account__c>();
                 
            for (sObject lo : listObj){
                processor.processRecord(lo);
                }

               insert inAcc; // The list object which i am modifying in the processRecord function has to be added to the database. So, is it

                                      // a good idea to add/populate the list in other function of other class
            }

 

global class CreateAndModifyProcessor {
    global void processRecord(sObject listObj){
        Unprocessed_Agreement__c temp = (Unprocessed_Agreement__c)listObj;
        
        Account__c tempAcc = new Account__c();
    
        inAcc.add(tempAcc); // This line throws an error
}
}

Hi All,

 

I am new to writing code in APEX. I have an Object 'UnProc' with 10 fields and it is 'POPULATED'. I have two more objects ('Account and Contact') with 5 fields each and these Objects have to be populated. I have to write an APEX code using the batch apex and scheduler so that i can create new records for 'Account' and 'Contact' takin the records which are already there in the 'UnProc'. After the Account and Contact fields get populated with the UnProc records. The UnProc record has to be deleted.

I have already read the batch apex and scheduler related docs on saleforce.com and have understood and created the class for them. But i am stuck at the implementation of my application. Pseoudo code or some lines of code can be useful.

Hi,

 

I have to calculate the agreement value for my new record .Assuming that agreement value is ending_days - begining_days. I have put this formula in my object.

IF(Beginning__c <> Ending__c,Ending__c-Beginning__c,0).

 

I have two questions related to this

 

1: What is the agreement value ?, Am i correct in assuming what i have assumed or does it some specific other meaning?

2: I have to create an agreement value for new records only. So, should i take care of this fact in my IF condition For example : should my IF code look something like this

IF (AND(//somehow check if the record is new,Beginning__c <> Ending__c),Ending__c-Beginning__c,0)

Hi All,

 

I am new to the concept of Cloud Computing in general and salesforce.com specifically and have a bit of Java experience. I have one task to be done and need commuinty's help in that. Below is the descritption of what is require of me and my questions related to that .

 

1 : Have to create a functionality  to run on schedule that processes the information (Custom Object)

2 : Schedule the functionality in Salesforce

3 : Upload a CSV file example to Unprocessed agreement custom object

 

My questions (Here i am anticipating some direct few lines answer and/or links to the related user guides or tutorials):

For 1: How to create a functionality and to make it run on schedule ?

For 2: What does this statement means ??

For 3: What is the significance of Comma Seperated Values, why and how it can be uploaded.

 

Once again, i am not looking for direct whole solution to this problem but some pointers/ hint to get me started and point me in the right direction  with the saleforce.com

 

Looking forward to hear from you

 

Thanks

 

 

Hi,

 

Can someone have a look at it. Below is the code and the error

 

global void execute(
        Database.BatchableContext BC,
        List<sObject> listObj){
            
            list <Account> inAcc = new list<Account>();
            for (sObject lo : listObj){
                Unprocessed_Agreement__c temp = (Unprocessed_Agreement__c)lo;
                inAcc.add(processor.processAccountRecord(temp));
                }
            insert(inAcc); // This line throws the error
            }

 

 

the processor class looks something like this

 

global class CreateAndModifyProcessor {
    global Account processAccountRecord( Unprocessed_Agreement__c temp){
        Account tempAcc = new Account();
        tempAcc.Begining__c = temp.Begining__c;
        tempAcc.Agreement_ID__c = temp.Agreement_ID__c;
        return tempAcc; 
    }
}

 

First error: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Name]: [Name]

 

Hi,

 

I am having this error.

First error: Insert failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: []

 

 

Tried deleting the records by using data loader but no success, also tried it by deleting the record by selecting all and deleting but the error comes

 

Cannot delete last list view. You can't delete the last list view that's Visible to all users or Visible to certain groups of users.

Hi,

I am developing an application in which i am retrieving records from an object and then want to insert (some of the fields of the) records into different objects. Below is my code in which i cannot figure it out that why my objects are not being populated and new record cannot be seen .

 

public with sharing class ScheduleBatchLauncher{
    public static String scheduleBatch(Datetime batchTime){
        CreateAndModifyScheduler batchSched = new CreateAndModifyScheduler();
        String cron = '20 25 * * * ?';
        String schedId = System.schedule('Create and Modify Batch 1', cron, batchSched);       
        return schedId;
    }

}

 

global class CreateAndModifyScheduler implements Schedulable{
   global void execute(SchedulableContext sc) {
      CreateAndModify scBatch = new CreateAndModify(); 
      database.executebatch(scBatch);
   }
}
global class CreateAndModify implements
Database.Batchable<sObject>, Database.Stateful{


    global CreateAndModifyProcessor processor;
    global CreateAndModify(){
            this.processor = new CreateAndModifyProcessor();
        }
    
    global Database.queryLocator start
        (Database.BatchableContext BC){
            return Database.getQueryLocator([Select Agreement_ID__c, Begining__c,
                                            Contact_Email__c, Contact_Name__c,
                                            Country_Code__c, Currency__c,
                                            Customer_Address__c, Customer_ID__c,
                                            Customer_Name__c,Customer_Postal_Code__c,
                                            Ending__c,Price__c FROM Unprocessed_Agreement__c]);
            }
    
    global void execute(
        Database.BatchableContext BC, 
        List<sObject> listObj){
            
            list <Account__c> inAcc = new list<Account__c>();
                       
            for (sObject lo : listObj){
                Unprocessed_Agreement__c temp = (Unprocessed_Agreement__c)lo;
                
                inAcc.add(processor.processAccountRecord(temp));    
                }
            insert(inAcc);
update(inAcc)
  } global void finish( Database.BatchableContext BC){ } }

 

global class CreateAndModifyProcessor {
    global Account__c processAccountRecord( Unprocessed_Agreement__c temp){
        Account__c tempAcc = new Account__c();
        tempAcc.Customer_Name__c = temp.Customer_Name__c;
        tempAcc.Customer_Address__c = temp.Customer_Address__c;
        tempAcc.Postal_Code__c = temp.Customer_Postal_Code__c;
        return tempAcc;
    }   
}

 

 Please if someone can have a look at it. Also, if someone wants to see my build.xml or package.xml please tell..Thank You

Hi,

I have couple of objects, In which i have defined a few custom field and one field as a standard field.

First, i will try to explain the reason why i have defined one field as a standard field.

The couple of object which i have defined represents the record and in my app if the record is already in the system i have to update its values. For every object i have been given a key like for eg for 'Contact' object i have been given 'Contact Email ' as a key. So, i have made the contact email as the standard field while the contact name as the custome field.

 

So, my question is,

1 : that does it even matters that if the key is custom or standard field ?

2 : Why there is no API name for standard field. how can one access standard field from apex code without it having the API name?

Also last but not the least

3 : what is the significance of having a key, i mean if a field is key then in what way is it seperate from other field .

 

Thanks

 

Hi All,

 

I am new to writing code in APEX. I have an Object 'UnProc' with 10 fields and it is 'POPULATED'. I have two more objects ('Account and Contact') with 5 fields each and these Objects have to be populated. I have to write an APEX code using the batch apex and scheduler so that i can create new records for 'Account' and 'Contact' takin the records which are already there in the 'UnProc'. After the Account and Contact fields get populated with the UnProc records. The UnProc record has to be deleted.

I have already read the batch apex and scheduler related docs on saleforce.com and have understood and created the class for them. But i am stuck at the implementation of my application. Pseoudo code or some lines of code can be useful.

Hi,

 

I have to calculate the agreement value for my new record .Assuming that agreement value is ending_days - begining_days. I have put this formula in my object.

IF(Beginning__c <> Ending__c,Ending__c-Beginning__c,0).

 

I have two questions related to this

 

1: What is the agreement value ?, Am i correct in assuming what i have assumed or does it some specific other meaning?

2: I have to create an agreement value for new records only. So, should i take care of this fact in my IF condition For example : should my IF code look something like this

IF (AND(//somehow check if the record is new,Beginning__c <> Ending__c),Ending__c-Beginning__c,0)

Is there any way to mass delete records in a custom object (table)?  The Mass Delete feature under Setup -> Administration Setup -> Data Management -> Mass Delete Records  only seems to perform a mass delete for SDFC standard objects....

 

It is pretty painful to delete records one by one - phew!!

 

 

  • December 21, 2009
  • Like
  • 0