• Kiransssssssssssssssssss
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies

In JS how are the values passed. what i know is while calling a method based on the position of the values, those are assigned to the parameters. If the mthod is add(int a , int b) { ....  logic ....}

add(1,3) --> a =1, b = 3 and then the logic will happen. But in javascript i am facing some difficulty to understand how this is working.
 

In the below example, how are the values assigned to the parameters inside the function. i.e. validFields and inputComp.  the reduce function is just called with a function inside. 

 

({
    validateFields : function(component, event, helper)  {
        var isValid  = component.find('newContact').reduce(function(validFields,inputComp){
            inputComp.showHelpMessageIfInvalid();
            inputComp.set('v.validity',{valid:false,badInput:true});
            return validFields && inputComp.get('v.validity').valid
        },true);
      
    }
})

 

1 -- Please help me understand the concepthelp how are the variables getting the values in these type of scenarios.

2 -- Where can I find detailed info about using functions / variables this way.

I want to capture the Territory Ids the user is assigned to. I wrote the trigger and the logs show the value that i am expecting, but the record is not getting updated. Could you suggest me please?

trigger preventTerritoryAssignmentDeletion on User (before update) {
    
    Set<Id> userIds = new Set<Id>();
    List<User> UT2List = new List<User>();
   
    for(User u : Trigger.New){
        if(u.Resource_ID__c == 'testresourceid'){
            //u.Territory_Backup_IDs__c = 'workinig';
            userIds.add(u.Id);
        }
    }
    
        UT2List = [SELECT ID,Territory_Backup_IDs__c, (SELECT ID,Territory2Id FROM UserTerritory2Associations) FROM User WHERE Id IN :userIds];
		
        for(User u : UT2List){
            string terrString =',';
            for(UserTerritory2Association ut2a : u.UserTerritory2Associations){
                terrString = terrString + ut2a.Territory2Id +',';
                system.debug('terrString inside inner for loop'+terrString);
               
            }
           
            system.debug('terrString in out for loop'+terrString);
            system.debug('u.Territory_Backup_IDs__c'+ u.Territory_Backup_IDs__c);
            u.Territory_Backup_IDs__c =u.Territory_Backup_IDs__c+ terrString;
            system.debug('u.Territory_Backup_IDs__c'+ u.Territory_Backup_IDs__c);
            }
          
    
}
Thank you in advance!

Hi All,

There are many Record Types on an object. I want to know about each of the values in a picklist, i.e. which are all the record types where that  picklist vfield value is available . I want to do some comparision. Is there any URL hacking   solution or some other easy way to do it. 

Thanks in advance

I want to capture the Territory Ids the user is assigned to. I wrote the trigger and the logs show the value that i am expecting, but the record is not getting updated. Could you suggest me please?

trigger preventTerritoryAssignmentDeletion on User (before update) {
    
    Set<Id> userIds = new Set<Id>();
    List<User> UT2List = new List<User>();
   
    for(User u : Trigger.New){
        if(u.Resource_ID__c == 'testresourceid'){
            //u.Territory_Backup_IDs__c = 'workinig';
            userIds.add(u.Id);
        }
    }
    
        UT2List = [SELECT ID,Territory_Backup_IDs__c, (SELECT ID,Territory2Id FROM UserTerritory2Associations) FROM User WHERE Id IN :userIds];
		
        for(User u : UT2List){
            string terrString =',';
            for(UserTerritory2Association ut2a : u.UserTerritory2Associations){
                terrString = terrString + ut2a.Territory2Id +',';
                system.debug('terrString inside inner for loop'+terrString);
               
            }
           
            system.debug('terrString in out for loop'+terrString);
            system.debug('u.Territory_Backup_IDs__c'+ u.Territory_Backup_IDs__c);
            u.Territory_Backup_IDs__c =u.Territory_Backup_IDs__c+ terrString;
            system.debug('u.Territory_Backup_IDs__c'+ u.Territory_Backup_IDs__c);
            }
          
    
}
Thank you in advance!

Hi All,

There are many Record Types on an object. I want to know about each of the values in a picklist, i.e. which are all the record types where that  picklist vfield value is available . I want to do some comparision. Is there any URL hacking   solution or some other easy way to do it. 

Thanks in advance