• SF_musaleme
  • NEWBIE
  • 0 Points
  • Member since 2009

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

Hi,

I am writing a trigger in apex.

I have to update user Salesforce object depending on some condition.

For this, I have one csv file which contains the ID for updation.

I have written one process in process-conf.xml file for the updation of record.

When record from csv file is invoked for the updation,then I am checking one field of that record in USer table.

Based on the value of that field I need to update record.else I dont need to update that record.

Means I am updating the same record on which I have invoked trigger but only when the condtion matches.

 

This is the code :

trigger AutoDeactivateSSO on User (before update)
{
 if (Trigger.isBefore) 
 {
      Set<ID> userIds = new Set<ID>();
      for (User apNew : Trigger.new) 
      {
        System.debug('no of records in trigger invocation-->'+Trigger.size); 
        System.debug('value of apNew.SSO_Id__c-->'+ apNew.SSO_Id__c); 
        Map<ID, User> userRecords = new Map<ID, User>([
           SELECT Id,IsActive,SSO_Id__c,EmployeeNumber
            FROM   User
            WHERE  Id in :Trigger.new
          ]);
          
          for (ID i : userRecords.keySet()) 
          {
           System.debug('userRecords Id:'+userRecords.get(i).Id);
           System.debug('userRecords IsActive:'+userRecords.get(i).IsActive);
           System.debug('userRecords EmployeeNumber:'+userRecords.get(i).EmployeeNumber);
          }

       /* if (!userIds.contains(apNew.SSO_Id__c))
         userIds.add(apNew.SSO_Id__c);
        
        System.debug('UserIds size:'+userIds.size());*/
      }
       }
}

 

Please reply.Your reply will be valuable.

 

Hi,

I am writing a trigger in apex.

I have to update user Salesforce object depending on some condition.

For this, I have one csv file which contains the ID for updation.

I have written one process in process-conf.xml file for the updation of record.

When record from csv file is invoked for the updation,then I am checking one field of that record in USer table.

Based on the value of that field I need to update record.else I dont need to update that record.

Means I am updating the same record on which I have invoked trigger but only when the condtion matches.

 

This is the code :

trigger AutoDeactivateSSO on User (before update)
{
 if (Trigger.isBefore) 
 {
      Set<ID> userIds = new Set<ID>();
      for (User apNew : Trigger.new) 
      {
        System.debug('no of records in trigger invocation-->'+Trigger.size); 
        System.debug('value of apNew.SSO_Id__c-->'+ apNew.SSO_Id__c); 
        Map<ID, User> userRecords = new Map<ID, User>([
           SELECT Id,IsActive,SSO_Id__c,EmployeeNumber
            FROM   User
            WHERE  Id in :Trigger.new
          ]);
          
          for (ID i : userRecords.keySet()) 
          {
           System.debug('userRecords Id:'+userRecords.get(i).Id);
           System.debug('userRecords IsActive:'+userRecords.get(i).IsActive);
           System.debug('userRecords EmployeeNumber:'+userRecords.get(i).EmployeeNumber);
          }

       /* if (!userIds.contains(apNew.SSO_Id__c))
         userIds.add(apNew.SSO_Id__c);
        
        System.debug('UserIds size:'+userIds.size());*/
      }
       }
}

 

Please reply.Your reply will be valuable.

 

     1) Is dataload in command line support Upsert function?
2) Is dataload in command line support support mapping by external id?
3) I succsessfully success to extract data from command line, however when i ttrying to perform updated i am getting the following error:
2007-03-29 22:53:01,015 ERROR [main] client.PartnerClient loadUpdates (PartnerClient.java:544) - Errors were found on item 199
2007-03-29 22:53:01,016 ERROR [main] client.PartnerClient loadUpdates (PartnerClient.java:546) - Error code is: MISSING_ARGUMENT
2007-03-29 22:53:01,016 ERROR [main] client.PartnerClient loadUpdates (PartnerClient.java:547) - Error message: Id not specified in an update call

My mapping file looks like this

ID=id
CREATEDDATE=ProductCode
DESCRIPTION=Description
FAMILY=Family
PRODUCT_TYPE__C=Product_Type__c
FORECAST_FAMILY__C=Forecast_Family__c
NAME=Name
INVENTORY_ITEM_ID__C=Inventory_Item_id__c

What Am i doing wrong?