• Nikitha
  • NEWBIE
  • 30 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 22
    Questions
  • 11
    Replies
Hii All, 
 
How can we connect with SOAP when the MFA API logins was enable?
I am getting an error message  INVALID_LOGIN . How can I solve that problem? 
Hii !
Can anyone tell me how to delete a record based on date changes? I am looking to delete records based on a date using flows. for example, if I am creating a record today the next day the created record should be deleted using flows. How can I do that and can anyone give some examples, please?

Thanks in advance! 
 
  • September 30, 2021
  • Like
  • 0
When I search for a user with email, portal user contact and user record will be there.
but when I search with the email only the contact record is showing not user records
can someone tell me what setting I need to enable to display user records also?
 
Hi, I am struggling  in integration. I have created a code and the response is internal server err.  please can anybody tell me what I have done wrong? I'm new to integration. my requirement is I have to create a javascript button. when I am clicking the button should send a request to Api and response should be updated Course Ids. How can I achieve that. I have  referred some posts but I didn't able to find what i have done wrong.
 my code.

global with sharing class CreateCourseInMoodle 
{
    public static final String token = PROFG_LMS_Setting__c.getValues('LMS_WS_Token').Value__c;
    public static final string categoryid = PROFG_LMS_Setting__c.getValues('BE_CategoryId').Value__c;
    public static final String endPoint = PROFG_LMS_Setting__c.getValues('LMS_EndPoint').value__c ;
    webservice static string requestMoodleCourse(String courseId)
    {
        system.debug('Ids'+courseId);
       List< Moodle_course__c> course = ((MoodleCoursesSelector_PG) Application_PG.selector.newInstance(Moodle_Course__c.SObjectType)).selectById(new Set<Id> {courseId});
        Map<String, String> inputsForCourse = new Map<String, String>();
        inputsForCourse.put('wstoken ', token);
        inputsForCourse.put('moodlewsrestformat', 'json');
        inputsForCourse.put('wsfunction','core_course_create_courses');
        inputsForCourse.put('courses[0][fullname]',course[0].Name);
        inputsForCourse.put('courses[0][shortname]',course[0].Name);
        inputsForCourse.put('courses[0][categoryid]', categoryid);
        inputsForCourse.put('courses[0][idnumber]',courseId);
        inputsForCourse.put('courses[0][summary]', course[0].Description__c);
        inputsForCourse.put('courses[0][summaryformat]','1');
        inputsForCourse.put('courses[0][format]','topics');
        inputsForCourse.put('courses[0][showgrades]','0');
        inputsForCourse.put('courses[0][newsitems]','0');
        inputsForCourse.put('courses[0][numsections]','2');
        inputsForCourse.put('courses[0][maxbytes]','2');
        inputsForCourse.put('courses[0][showreports]','0');
        inputsForCourse.put('courses[0][visible]','1');
        inputsForCourse.put('courses[0][hiddensections]','0');
        inputsForCourse.put('courses[0][enablecompletion]','1');
        inputsForCourse.put('courses[0][lang]','en');
        inputsForCourse.put('courses[0][groupmode]','0');
        inputsForCourse.put('courses[0][groupmodeforce]','0');
        inputsForCourse.put('courses[0][defaultgroupingid]','0');
        inputsForCourse.put('courses[0][customfields][0][shortname]','Country');
        inputsForCourse.put('courses[0][customfields][0][value]',course[0].Country__c);
        system.debug('mapOfcourse '+inputsForCourse);
        
        
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint(endPoint);
        system.debug('endpoint'+endPoint);
        request.setMethod('GET');
        HttpResponse response = http.send(request);
          
        response = http.send(request);
        System.debug(response.getStatus());
        System.debug(response.getBody());
        if(response.getStatusCode() == 200)
        {
            system.debug('Success');
        }else
        {
            system.debug('Failure');
        }
        return response.getStatus();
    }
}
Hi new to salesforce I'm trying validation using trigger I'm getting above err
 my class code is
 @HttpPost
   global static void createUser(List<User> userList,String Firstname,String Lastname,  String alias,String ProfileId,String Email,
                                String   TimeZoneSidKey,String LanguageLocaleKey,String CommunityNickname,
                               String EmailEncodingKey,String LocaleSidKey,String UserName)
   {
       
       Profile customProfile = [Select id From profile Where Name ='Custom Profile' Limit 1];
       for(User newUser : userList){
        newUser.Firstname = firstname;
        newUser.Lastname = lastname;
        newUser.CommunityNickname = CommunityNickname;
        newUser.Email = email;
       if(String.isBlank(newUser.Email))
       {
           newUser.addError('Enter Email ');
       }
        newUser.Alias = alias;
        newUser.Username = username;
        newUser.ProfileId = customProfile.id ;
        newUser.TimeZoneSidKey = TimeZoneSidKey;
        newUser.LanguageLocaleKey = LanguageLocaleKey;
        newUser.EmailEncodingKey = EmailEncodingKey;
        newUser.LocaleSidKey = LocaleSidKey;
        insert newUser;
                                 
    }
   }
 please help me
 
my code
 @HttpPut
     global static Id upsertUser(String Firstname,String Lastname,  String alias,String ProfileId,String Email,
                                String   TimeZoneSidKey,String LanguageLocaleKey,
                               String EmailEncodingKey,String LocaleSidKey,String UserName)
   {
      
           User updateUser = new  User();
        updateUser.Firstname = firstname;
        updateUser.Lastname = lastname;
        updateUser.Email = email;
        updateUser.Alias = alias;
        updateUser.Username = username;
        updateUser.ProfileId = ProfileId ;
        updateUser.TimeZoneSidKey = TimeZoneSidKey;
        updateUser.LanguageLocaleKey = LanguageLocaleKey;
        updateUser.EmailEncodingKey = EmailEncodingKey;
        updateUser.LocaleSidKey = LocaleSidKey;
        upsert updateUser; 
           
        return updateUser.Id;                                
        
    }      
    
TriggeronContact: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, only portal users can be associated to a contact: [] Trigger.TriggeronContact: line 32, column 1

my code is
trigger TriggeronContact on Contact (After insert) {
    Set<ID> contactids = new Set<ID>();
    for(Contact c : Trigger.new){
        if(c.LastName != null ){
            Contactids.add(c.Id);
        }
    }
    List<Contact> conlist =[Select id, email,FirstName,LastName  from Contact where Id IN : contactids];
    List<User> userList = new List<User>();
    for(Contact con : trigger.new){
        string nick = con.email!=null?con.email.substring(0, con.email.indexOf('@')):''; 
        nick += Datetime.now().getTime();
        List<Profile> profileList = [Select Id from Profile where Name=: 'System Administrator' limit 1];
        
        User newuser = new User(Alias = con.FirstName,
                                email = con.Email,
                                emailencodingkey = 'UTF-8',
                                firstname = con.FirstName,
                                lastname = con.LastName,
                                localesidkey = 'en_US',
                                contactId = con.Id,
                                timezonesidkey='America/Los_Angeles',
                                IsActive = true,
                                username = con.Email,
                                CommunityNickname = nick,
                                ProfileId =  profileList[0].Id,
                                LanguageLocaleKey = 'en_US');
                          userList.add(newuser);
}
    insert userList;

}


how i need to clear this err msg
trigger CustomerDetailName on Customer_Detail__c (Before insert,after insert) {
    List<Dup_Customer_Detail__c> dupList = new List<Dup_Customer_Detail__c>();
    for(Customer_Detail__c customer : trigger.new){
        if(trigger.IsBefore && trigger.isInsert){
        customer.Name= customer.Name + '.' + customer.Last_name__c;
    }
      else  if(trigger.IsAfter && trigger.isInsert){
        Dup_Customer_Detail__c dup =new Dup_Customer_Detail__c();
        dup.Name = customer.Name;
        dup.Last_Name__c = customer.Last_name__c;
        
        dupList.add(dup);
    
    }
  
    }
    if(!dupList.isEmpty()){
    insert dupList;
    }
trigger AccountCustomerDetail on Customer_Detail__c (before insert) {
    set<id>accountId = new set<id>();
    for(Customer_Detail__c customer : trigger.new){
        accountId.add(customer.id);
    }
List<Account> acclist = [Select id,BillingStreet,BillingCity from Account 
                        where id in: accountId];
    Map<id,Account>accMap = new Map<id,Account>();
    for(Account acc: trigger.new){
        accMap.put(acc.id, acc);
    }
    for(Customer_Detail__c customer : Trigger.new){
        customer.APShipping_Street__c = accMap.get(customer.Id).BillingStreet;
        customer.AP_Shipping_City__c = accMap.get(customer.Id).BillingCity;
    }
}

Err is  Line 9 Invalid loop variable type expected Customer_Detail__c was Account. Please help me to solve this.
my code

public class CollegeActions {
   public static boolean flag = true;
    public static void createMarkSheet(List<college__c> collegeList ){
        List<Mark_Sheet__c> marksheetList = new List<Mark_Sheet__c>();
        for(college__c college :collegeList ){
            Mark_Sheet__c mark = new Mark_Sheet__c();
            mark.Name = college.Name;
            mark.Last_Name__c = college.Last_Name__c;
            marksheetList.add(mark);
            
        }
        if(!marksheetList.isEmpty()){
          insert marksheetList;
            
        }
        
        }
    }

In trigger 

trigger collegeInsertTrigger on college__c (after insert,after update) {
        if( CollegeActions.flag== True)
    {
        CollegeActions.flag = false;
         CollegeActions.createMarkSheet(Trigger.new);
    }
}

 
When I search for a user with email, portal user contact and user record will be there.
but when I search with the email only the contact record is showing not user records
can someone tell me what setting I need to enable to display user records also?
 
Hi new to salesforce I'm trying validation using trigger I'm getting above err
 my class code is
 @HttpPost
   global static void createUser(List<User> userList,String Firstname,String Lastname,  String alias,String ProfileId,String Email,
                                String   TimeZoneSidKey,String LanguageLocaleKey,String CommunityNickname,
                               String EmailEncodingKey,String LocaleSidKey,String UserName)
   {
       
       Profile customProfile = [Select id From profile Where Name ='Custom Profile' Limit 1];
       for(User newUser : userList){
        newUser.Firstname = firstname;
        newUser.Lastname = lastname;
        newUser.CommunityNickname = CommunityNickname;
        newUser.Email = email;
       if(String.isBlank(newUser.Email))
       {
           newUser.addError('Enter Email ');
       }
        newUser.Alias = alias;
        newUser.Username = username;
        newUser.ProfileId = customProfile.id ;
        newUser.TimeZoneSidKey = TimeZoneSidKey;
        newUser.LanguageLocaleKey = LanguageLocaleKey;
        newUser.EmailEncodingKey = EmailEncodingKey;
        newUser.LocaleSidKey = LocaleSidKey;
        insert newUser;
                                 
    }
   }
 please help me
 
my code
 @HttpPut
     global static Id upsertUser(String Firstname,String Lastname,  String alias,String ProfileId,String Email,
                                String   TimeZoneSidKey,String LanguageLocaleKey,
                               String EmailEncodingKey,String LocaleSidKey,String UserName)
   {
      
           User updateUser = new  User();
        updateUser.Firstname = firstname;
        updateUser.Lastname = lastname;
        updateUser.Email = email;
        updateUser.Alias = alias;
        updateUser.Username = username;
        updateUser.ProfileId = ProfileId ;
        updateUser.TimeZoneSidKey = TimeZoneSidKey;
        updateUser.LanguageLocaleKey = LanguageLocaleKey;
        updateUser.EmailEncodingKey = EmailEncodingKey;
        updateUser.LocaleSidKey = LocaleSidKey;
        upsert updateUser; 
           
        return updateUser.Id;                                
        
    }      
    
TriggeronContact: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, only portal users can be associated to a contact: [] Trigger.TriggeronContact: line 32, column 1

my code is
trigger TriggeronContact on Contact (After insert) {
    Set<ID> contactids = new Set<ID>();
    for(Contact c : Trigger.new){
        if(c.LastName != null ){
            Contactids.add(c.Id);
        }
    }
    List<Contact> conlist =[Select id, email,FirstName,LastName  from Contact where Id IN : contactids];
    List<User> userList = new List<User>();
    for(Contact con : trigger.new){
        string nick = con.email!=null?con.email.substring(0, con.email.indexOf('@')):''; 
        nick += Datetime.now().getTime();
        List<Profile> profileList = [Select Id from Profile where Name=: 'System Administrator' limit 1];
        
        User newuser = new User(Alias = con.FirstName,
                                email = con.Email,
                                emailencodingkey = 'UTF-8',
                                firstname = con.FirstName,
                                lastname = con.LastName,
                                localesidkey = 'en_US',
                                contactId = con.Id,
                                timezonesidkey='America/Los_Angeles',
                                IsActive = true,
                                username = con.Email,
                                CommunityNickname = nick,
                                ProfileId =  profileList[0].Id,
                                LanguageLocaleKey = 'en_US');
                          userList.add(newuser);
}
    insert userList;

}


how i need to clear this err msg
trigger AccountCustomerDetail on Customer_Detail__c (before insert) {
    set<id>accountId = new set<id>();
    for(Customer_Detail__c customer : trigger.new){
        accountId.add(customer.id);
    }
List<Account> acclist = [Select id,BillingStreet,BillingCity from Account 
                        where id in: accountId];
    Map<id,Account>accMap = new Map<id,Account>();
    for(Account acc: trigger.new){
        accMap.put(acc.id, acc);
    }
    for(Customer_Detail__c customer : Trigger.new){
        customer.APShipping_Street__c = accMap.get(customer.Id).BillingStreet;
        customer.AP_Shipping_City__c = accMap.get(customer.Id).BillingCity;
    }
}

Err is  Line 9 Invalid loop variable type expected Customer_Detail__c was Account. Please help me to solve this.
Greetings:

I have been trying to do check the challenge of the the first part of the "Apex Basics & Database" module. I have been restructuring my apex code but nothing seems to work. This is the error that I'm getting:
User-added image