• colin Berrouard
  • NEWBIE
  • 50 Points
  • Member since 2016
  • Business Analyst
  • Fujitsu

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

I am searching a solution for my application to load data in an object from another object. 
Use Case:
he user will activate the data loading. Once the data loading is finished, the user will be able to continue his job.

do you have any idea ?

thanks
Hi

I have this error "Error: Compile Error: Method does not exist or incorrect signature: [Schema.SObjectField].addError(String) at line 15 column 17"

trigger NameDuplicatePrevent on Team__C
                               (before insert, before update) {

    Map<String, Team__c> teamMap = new Map<String, Team__c>();
    for (Team__c team : System.Trigger.new) {
                   
        if ((Team__c.Name != null) &&
                (System.Trigger.isInsert ||
                (Team__c.Name != 
                    System.Trigger.oldMap.get(Team__c.Id).Name))) {
                
            // Make sure another new Team isn't also a duplicate  
    
            if (teamMap.containsKey(Team__c.Name)) {
                Team__c.Name.addError('Another Team Name exist');  <--- error line
            } else {
                teamMap.put(Team__c.Name, Team);
            }
       }
    }
        
    for (Team__c team : [SELECT Name FROM Team__c
                      WHERE Name IN :teamMap.KeySet()]) {
        Team__c newTeam = teamMap.get(Team__c.Name);
        newTeam.Name.addError('A Name already exist. ');
    }
}

Here is the TEAM object description
User-added image

Thamks

colin
 
Hi
I have these objects
User-added image
In  "reservation Terrain" layout, i have a the lookup field "Terrain_disponible" which display only "No terrain dispo" and would like to displat also the fields  Availble and Terrain_disponible. How can I do it ?
User-added image
Also, the lookup display only 8 rows and I have 20 rows, Could tell me how to display alle the rows.

Thanks

colin
Hi
I have an Insert trigger (after insert) on object Reservation Terrain than update Terrain Disponible object.
I have to update the Terrain_Disponible.Available field to "NO", and update Terrain_Disponible.Date_reserve field to Reservation_Terrain.Date_de_reservation value

Here is the schema

User-added image

Here the code with an error at line 13
trigger TRG_Reservation2 on Reservation_Terrain__c (after insert) {
    Set<Id> tdIdSet = new Set<Id>();
    for(Reservation_Terrain__c rt: Trigger.new) {
        if(rt.Terrain_Disponible__c != null)
            tdIdSet.add(rt.Terrain_Disponible__c);
    }
   
    if(!tdIdSet.isEmpty()) {
        List<Terrain_Disponible__c> tdList = [SELECT Id, Name, Available__c, Date_reserve__c FROM Terrain_Disponible__c WHERE Id IN: tdIdSet];
       
        for(Terrain_Disponible__c td: tdList) {
            td.Available__c = 'NO';
            td.Date_reserve__c = Date_de_reservation__c.new;  <-- The error line
        }
        update tdList;
    }
}

Could you give me a hand?

thank you

 
I am new in Salesforce
When I insert an object, I want to update a record of another object.
So I use a trigger after insert

My code
trigger TRG_Reservation on Reservation_Field__c (after insert) {
 Available_Field__c a = [SELECT Name FROM Available_Field__c WHERE Name = :name];
      a.available_flag = 'NO';
      update a;
}

Thanks for your help

​colin
Hi

I have this error "Error: Compile Error: Method does not exist or incorrect signature: [Schema.SObjectField].addError(String) at line 15 column 17"

trigger NameDuplicatePrevent on Team__C
                               (before insert, before update) {

    Map<String, Team__c> teamMap = new Map<String, Team__c>();
    for (Team__c team : System.Trigger.new) {
                   
        if ((Team__c.Name != null) &&
                (System.Trigger.isInsert ||
                (Team__c.Name != 
                    System.Trigger.oldMap.get(Team__c.Id).Name))) {
                
            // Make sure another new Team isn't also a duplicate  
    
            if (teamMap.containsKey(Team__c.Name)) {
                Team__c.Name.addError('Another Team Name exist');  <--- error line
            } else {
                teamMap.put(Team__c.Name, Team);
            }
       }
    }
        
    for (Team__c team : [SELECT Name FROM Team__c
                      WHERE Name IN :teamMap.KeySet()]) {
        Team__c newTeam = teamMap.get(Team__c.Name);
        newTeam.Name.addError('A Name already exist. ');
    }
}

Here is the TEAM object description
User-added image

Thamks

colin
 
Hi
I have these objects
User-added image
In  "reservation Terrain" layout, i have a the lookup field "Terrain_disponible" which display only "No terrain dispo" and would like to displat also the fields  Availble and Terrain_disponible. How can I do it ?
User-added image
Also, the lookup display only 8 rows and I have 20 rows, Could tell me how to display alle the rows.

Thanks

colin
Hi
I have an Insert trigger (after insert) on object Reservation Terrain than update Terrain Disponible object.
I have to update the Terrain_Disponible.Available field to "NO", and update Terrain_Disponible.Date_reserve field to Reservation_Terrain.Date_de_reservation value

Here is the schema

User-added image

Here the code with an error at line 13
trigger TRG_Reservation2 on Reservation_Terrain__c (after insert) {
    Set<Id> tdIdSet = new Set<Id>();
    for(Reservation_Terrain__c rt: Trigger.new) {
        if(rt.Terrain_Disponible__c != null)
            tdIdSet.add(rt.Terrain_Disponible__c);
    }
   
    if(!tdIdSet.isEmpty()) {
        List<Terrain_Disponible__c> tdList = [SELECT Id, Name, Available__c, Date_reserve__c FROM Terrain_Disponible__c WHERE Id IN: tdIdSet];
       
        for(Terrain_Disponible__c td: tdList) {
            td.Available__c = 'NO';
            td.Date_reserve__c = Date_de_reservation__c.new;  <-- The error line
        }
        update tdList;
    }
}

Could you give me a hand?

thank you

 
I am new in Salesforce
When I insert an object, I want to update a record of another object.
So I use a trigger after insert

My code
trigger TRG_Reservation on Reservation_Field__c (after insert) {
 Available_Field__c a = [SELECT Name FROM Available_Field__c WHERE Name = :name];
      a.available_flag = 'NO';
      update a;
}

Thanks for your help

​colin