Activity Forums Salesforce® Discussions Implementing Reset password in BOT commands that is included in Utility BAR in Salesforce

  • Implementing Reset password in BOT commands that is included in Utility BAR in Salesforce

    Posted by GEETANAJLI on March 5, 2018 at 10:55 am

    Hi Guys,

    I am new to Salesforce coding. I believe everybody knows abut BOT COMMANDS Utility bar. below is link

    https://developer.salesforce.com/blogs/developer-relations/2017/03/bot-toolkit-creating-deploying-bots-inside-salesforce.html

    So i have configured it in my salesforce app. Now i am trying to implement add on command reset password which will simply just reset the password of loginned user by sending reset user password email.  but my code is not working when i am including system.resetpassword(id, true). it is saving code but when i am passing parameter in BOt command nothing happening .please check my code and correct me where is am  wrong?

    public with sharing class HandlerResetUserP implements BotHandler {
    
    public BotResponse handle(String utterance, String[] params, Map<String, String> session) {
    // String key = '%' + params[0] + '%';
    // string result=' ';
    List<User> users =
    [SELECT Id, Username, name, aboutme, employeenumber,OHR_ID__c FROM user
    // WHERE name LIKE :key
    where Id = : UserInfo.getUserId()
    ORDER BY Name
    LIMIT 5];
    
    // List<BotRecord> records = new List<BotRecord>();
    
    for (user u : users) {
    //after disable resetpassword step, it is responding
    
    try
    {
    
    system.resetPassword(u.Id,true);
    
    return new BotResponse(new BotMessage('Bot', 'Reset done'));
    
    }
    catch(Exception e)
    {
    return new BotResponse(new BotMessage('Bot', 'some some error.'));
    }
    
    //system.debug('DONE: ' + u.Id);
    }
    
    return new BotResponse(new BotMessage('Bot', 'last line'));
    
    }
    }
    
    GEETANAJLI replied 6 years, 1 month ago 1 Member · 0 Replies
  • 0 Replies

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos

Popular Salesforce Infographics