• nbansal10
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 9
    Replies
Hi,

I have implemented Salesforce for outlook for one of my orgs. This syncs up my meetings as events in Salesforce.
I want to find out how many events were created in Salesforce from Outlook in last 1 year.
Any way to find this out?
Hi there

Would like to know if anyone has encountered this?  If some account's name is over 50 characters long, we would like to capture as much the first 50 characters but complete words in Name, and then the splii over to Name2.    We would not want to split a word in half. 

Any suggestions would be great.

Thanks!
Hi, I am looking for ditto below structure. Tried inline account hierarchy unmanaged package from appexchange.
Able to achieve some of it but still far from actual one.. This shows Apexpageblocktable/apex:datatable while that one is done using apex:repeat.
Any suggestions/ valid code snippets will help. Thanks in advance.


User-added image

Hello Guys..!!

 

I am getting error "Too many SQL Queries 101". Please help me on how to resolve this. I understood that I have to get the "Select" statement out from loop, but not sure how to do this. Any help will be appreciated,

 

public class uploadCSVcontroller {

public Blob contentFile { get; set; }
public String nameFile { get; set; }
public Integer rowCount { get; set; }
public Integer colCount { get; set; }

//User related variables
public List<User> usr{get;set;}
public Datetime lastlogin;
public Id usrId;
public String username;
public boolean isactive;

public List<List<String>> getResults() {
List<List<String>> parsedCSV = new List<List<String>>();
rowCount = 0;
colCount = 0;
if (contentFile != null){
String fileString = contentFile.toString();

parsedCSV = parseCSV(fileString, false);

system.debug('@@@@parsedCSV.get(0): '+parsedCSV.get(0));
system.debug('@@@@parsedCSV: '+parsedCSV);
rowCount = parsedCSV.size();
for (List<String> row : parsedCSV){
if (row.size() > colCount){
colCount = row.size();
}
}
}
return parsedCSV;
}


public static List<List<String>> parseCSV(String contents,Boolean skipHeaders) {
List<List<String>> allFields = new List<List<String>>();

contents = contents.replaceAll(',"""',',"DBLQT').replaceall('""",','DBLQT",');
contents = contents.replaceAll('""','DBLQT');
List<String> lines = new List<String>();
try {
//lines = contents.split('\n'); //correction: this only accomodates windows files
lines = contents.split('\r'); // using carriage return accomodates windows, unix, and mac files
} catch (System.ListException e) {
System.debug('Limits exceeded?' + e.getMessage());
}
Integer num = 0;
for(String line: lines) {
// check for blank CSV lines (only commas)
if (line.replaceAll(',','').trim().length() == 0) break;

List<String> fields = line.split(',');
List<String> cleanFields = new List<String>();
String compositeField;
Boolean makeCompositeField = false;
for(String field: fields) {
if (field.startsWith('"') && field.endsWith('"')) {
cleanFields.add(field.replaceAll('DBLQT','"'));
} else if (field.startsWith('"')) {
makeCompositeField = true;
compositeField = field;
} else if (field.endsWith('"')) {
compositeField += ',' + field;
cleanFields.add(compositeField.replaceAll('DBLQT','"'));
makeCompositeField = false;
} else if (makeCompositeField) {
compositeField += ',' + field;
} else {
cleanFields.add(field.replaceAll('DBLQT','"'));
}
}

allFields.add(cleanFields);
}
if (skipHeaders) allFields.remove(0);
return allFields;
}

public void resetpwd() {
system.debug('@@@@@ in resetpwd');
List<List<String>> parsedCSV = new List<List<String>>();
if (contentFile != null){
String fileString = contentFile.toString();
parsedCSV = parseCSV(fileString, false);
system.debug('@@@@parsedCSV in resetpwd: '+parsedCSV);
}
Integer count = 0;
system.debug('@@@@parsedCSV.size(): '+ parsedCSV.size());
while(count<parsedCSV.size()) {

usr=[select id,name,LastLoginDate, isactive, Username from User where Username= :parsedCSV.get(count)];
system.debug('_____________________'+usr);

for (User u : usr) {
lastlogin = u.LastLoginDate;
system.debug('@@@@@lastlogin' + lastlogin);
usrId = u.Id;
system.debug('@@@@@usrId' + usrId);
username = u.Username;
system.debug('@@@@@username'+ username);
isactive = u.isactive;
if(lastlogin==null && isactive == true) {

system.resetPassword(usrId, true);
}
}
}
}
}

Hi,

 

I have written the following code. Getting error "Too many SQL queries" when I am trying to call "resetpwd" from any method. 

 

public Blob contentFile { get; set; }
public String nameFile { get; set; }
public Integer rowCount { get; set; }
public Integer colCount { get; set; }

//User related variables
public List<User> usr{get;set;}
public Datetime lastlogin;
public Id usrId;
public String username;
public boolean isactive;

public List<List<String>> getResults() {
List<List<String>> parsedCSV = new List<List<String>>();
rowCount = 0;
colCount = 0;
if (contentFile != null){
String fileString = contentFile.toString();

parsedCSV = parseCSV(fileString, false);
system.debug('@@@@parsedCSV.get(0): '+parsedCSV.get(0));
system.debug('@@@@parsedCSV: '+parsedCSV);
rowCount = parsedCSV.size();
for (List<String> row : parsedCSV){
if (row.size() > colCount){
colCount = row.size();
}
}
}
return parsedCSV;
}


public static List<List<String>> parseCSV(String contents,Boolean skipHeaders) {
List<List<String>> allFields = new List<List<String>>();

contents = contents.replaceAll(',"""',',"DBLQT').replaceall('""",','DBLQT",');
contents = contents.replaceAll('""','DBLQT');
List<String> lines = new List<String>();
try {
//lines = contents.split('\n'); //correction: this only accomodates windows files
lines = contents.split('\r'); // using carriage return accomodates windows, unix, and mac files
} catch (System.ListException e) {
System.debug('Limits exceeded?' + e.getMessage());
}
Integer num = 0;
for(String line: lines) {
// check for blank CSV lines (only commas)
if (line.replaceAll(',','').trim().length() == 0) break;

List<String> fields = line.split(',');
List<String> cleanFields = new List<String>();
String compositeField;
Boolean makeCompositeField = false;
for(String field: fields) {
if (field.startsWith('"') && field.endsWith('"')) {
cleanFields.add(field.replaceAll('DBLQT','"'));
} else if (field.startsWith('"')) {
makeCompositeField = true;
compositeField = field;
} else if (field.endsWith('"')) {
compositeField += ',' + field;
cleanFields.add(compositeField.replaceAll('DBLQT','"'));
makeCompositeField = false;
} else if (makeCompositeField) {
compositeField += ',' + field;
} else {
cleanFields.add(field.replaceAll('DBLQT','"'));
}
}

allFields.add(cleanFields);
}
if (skipHeaders) allFields.remove(0);
return allFields;
}

public void resetpwd() {
system.debug('@@@@@ in resetpwd');
List<List<String>> parsedCSV = new List<List<String>>();
if (contentFile != null){
String fileString = contentFile.toString();
parsedCSV = parseCSV(fileString, false);
system.debug('@@@@parsedCSV in resetpwd: '+parsedCSV);
}
Integer count = 0;
system.debug('@@@@parsedCSV.size(): '+ parsedCSV.size());
while(count<parsedCSV.size()) {

usr=[select id,name,LastLoginDate, isactive, Username from User where Username= :parsedCSV.get(count)];
system.debug('_____________________'+usr);

for (User u : usr) {
lastlogin = u.LastLoginDate;
system.debug('@@@@@lastlogin' + lastlogin);
usrId = u.Id;
system.debug('@@@@@usrId' + usrId);
username = u.Username;
system.debug('@@@@@username'+ username);
isactive = u.isactive;
if(lastlogin==null && isactive == true) {

system.resetPassword(usrId, true);
}
}
}
}
}

Hello Guys,

 

I want to reset password and send an email for multiple users with no login history through apex. The code which I have written for even one user gives System.LimitException: DML currently not allowed. I am stuck on this issue for a while. Please help me out on this.

 

Apex code:

public class UserList{

public List<User> usr{get;set;}
public Datetime lastlogin;
public Id usrId;
public String username;
public UserList()
{
usr=[select id,name,LastLoginDate, Username from User where Username='xxx@rediffmail.com'];

for (User u : usr) {
lastlogin = u.LastLoginDate;
system.debug('@@@@@lastlogin' + lastlogin);
usrId = u.Id;
system.debug('@@@@@usrId' + usrId);
username = u.Username;
system.debug('@@@@@username'+ username);
if(lastlogin==null) {
system.resetPassword(usrId, true); //getting exception on this line, please help me out...!!


}

}
}

}

}

 

 

Hi,

We are facing a issue while deploying change sets to production environment from sandbox. The issue is with the code coverage.
To be precise the code coverage in sandbox instance is  84% while the code coverage in production instance is 71% which is not allowing the change sets to be deployed into the production environment.

The issue is restricting us from completing some crucial deliverables. 

Let us know a solution for this issue.
I followed the instructions here: http://rjpalombo.com/2013/11/counting-open-activities-salesforce/

That code works perfectly in my sandbox org and does what it needs. When I try to deploy to production I get the following error:

the following triggers have 0% code coverage. Each trigger must have at least 1% code coverage. OpportunityProductTrigger

The odd thing is that Trigger it refers to in the error  (OpportunityProduct Trigger) shows 100% code coverage and has long existed in the production org. The trigger was created by 1 of our contracted developers. I'm not a developer myself but understand all the basic concepts and slowly trying to learn.  

Hello Guys..!!

 

I am getting error "Too many SQL Queries 101". Please help me on how to resolve this. I understood that I have to get the "Select" statement out from loop, but not sure how to do this. Any help will be appreciated,

 

public class uploadCSVcontroller {

public Blob contentFile { get; set; }
public String nameFile { get; set; }
public Integer rowCount { get; set; }
public Integer colCount { get; set; }

//User related variables
public List<User> usr{get;set;}
public Datetime lastlogin;
public Id usrId;
public String username;
public boolean isactive;

public List<List<String>> getResults() {
List<List<String>> parsedCSV = new List<List<String>>();
rowCount = 0;
colCount = 0;
if (contentFile != null){
String fileString = contentFile.toString();

parsedCSV = parseCSV(fileString, false);

system.debug('@@@@parsedCSV.get(0): '+parsedCSV.get(0));
system.debug('@@@@parsedCSV: '+parsedCSV);
rowCount = parsedCSV.size();
for (List<String> row : parsedCSV){
if (row.size() > colCount){
colCount = row.size();
}
}
}
return parsedCSV;
}


public static List<List<String>> parseCSV(String contents,Boolean skipHeaders) {
List<List<String>> allFields = new List<List<String>>();

contents = contents.replaceAll(',"""',',"DBLQT').replaceall('""",','DBLQT",');
contents = contents.replaceAll('""','DBLQT');
List<String> lines = new List<String>();
try {
//lines = contents.split('\n'); //correction: this only accomodates windows files
lines = contents.split('\r'); // using carriage return accomodates windows, unix, and mac files
} catch (System.ListException e) {
System.debug('Limits exceeded?' + e.getMessage());
}
Integer num = 0;
for(String line: lines) {
// check for blank CSV lines (only commas)
if (line.replaceAll(',','').trim().length() == 0) break;

List<String> fields = line.split(',');
List<String> cleanFields = new List<String>();
String compositeField;
Boolean makeCompositeField = false;
for(String field: fields) {
if (field.startsWith('"') && field.endsWith('"')) {
cleanFields.add(field.replaceAll('DBLQT','"'));
} else if (field.startsWith('"')) {
makeCompositeField = true;
compositeField = field;
} else if (field.endsWith('"')) {
compositeField += ',' + field;
cleanFields.add(compositeField.replaceAll('DBLQT','"'));
makeCompositeField = false;
} else if (makeCompositeField) {
compositeField += ',' + field;
} else {
cleanFields.add(field.replaceAll('DBLQT','"'));
}
}

allFields.add(cleanFields);
}
if (skipHeaders) allFields.remove(0);
return allFields;
}

public void resetpwd() {
system.debug('@@@@@ in resetpwd');
List<List<String>> parsedCSV = new List<List<String>>();
if (contentFile != null){
String fileString = contentFile.toString();
parsedCSV = parseCSV(fileString, false);
system.debug('@@@@parsedCSV in resetpwd: '+parsedCSV);
}
Integer count = 0;
system.debug('@@@@parsedCSV.size(): '+ parsedCSV.size());
while(count<parsedCSV.size()) {

usr=[select id,name,LastLoginDate, isactive, Username from User where Username= :parsedCSV.get(count)];
system.debug('_____________________'+usr);

for (User u : usr) {
lastlogin = u.LastLoginDate;
system.debug('@@@@@lastlogin' + lastlogin);
usrId = u.Id;
system.debug('@@@@@usrId' + usrId);
username = u.Username;
system.debug('@@@@@username'+ username);
isactive = u.isactive;
if(lastlogin==null && isactive == true) {

system.resetPassword(usrId, true);
}
}
}
}
}

Hi,

 

I have written the following code. Getting error "Too many SQL queries" when I am trying to call "resetpwd" from any method. 

 

public Blob contentFile { get; set; }
public String nameFile { get; set; }
public Integer rowCount { get; set; }
public Integer colCount { get; set; }

//User related variables
public List<User> usr{get;set;}
public Datetime lastlogin;
public Id usrId;
public String username;
public boolean isactive;

public List<List<String>> getResults() {
List<List<String>> parsedCSV = new List<List<String>>();
rowCount = 0;
colCount = 0;
if (contentFile != null){
String fileString = contentFile.toString();

parsedCSV = parseCSV(fileString, false);
system.debug('@@@@parsedCSV.get(0): '+parsedCSV.get(0));
system.debug('@@@@parsedCSV: '+parsedCSV);
rowCount = parsedCSV.size();
for (List<String> row : parsedCSV){
if (row.size() > colCount){
colCount = row.size();
}
}
}
return parsedCSV;
}


public static List<List<String>> parseCSV(String contents,Boolean skipHeaders) {
List<List<String>> allFields = new List<List<String>>();

contents = contents.replaceAll(',"""',',"DBLQT').replaceall('""",','DBLQT",');
contents = contents.replaceAll('""','DBLQT');
List<String> lines = new List<String>();
try {
//lines = contents.split('\n'); //correction: this only accomodates windows files
lines = contents.split('\r'); // using carriage return accomodates windows, unix, and mac files
} catch (System.ListException e) {
System.debug('Limits exceeded?' + e.getMessage());
}
Integer num = 0;
for(String line: lines) {
// check for blank CSV lines (only commas)
if (line.replaceAll(',','').trim().length() == 0) break;

List<String> fields = line.split(',');
List<String> cleanFields = new List<String>();
String compositeField;
Boolean makeCompositeField = false;
for(String field: fields) {
if (field.startsWith('"') && field.endsWith('"')) {
cleanFields.add(field.replaceAll('DBLQT','"'));
} else if (field.startsWith('"')) {
makeCompositeField = true;
compositeField = field;
} else if (field.endsWith('"')) {
compositeField += ',' + field;
cleanFields.add(compositeField.replaceAll('DBLQT','"'));
makeCompositeField = false;
} else if (makeCompositeField) {
compositeField += ',' + field;
} else {
cleanFields.add(field.replaceAll('DBLQT','"'));
}
}

allFields.add(cleanFields);
}
if (skipHeaders) allFields.remove(0);
return allFields;
}

public void resetpwd() {
system.debug('@@@@@ in resetpwd');
List<List<String>> parsedCSV = new List<List<String>>();
if (contentFile != null){
String fileString = contentFile.toString();
parsedCSV = parseCSV(fileString, false);
system.debug('@@@@parsedCSV in resetpwd: '+parsedCSV);
}
Integer count = 0;
system.debug('@@@@parsedCSV.size(): '+ parsedCSV.size());
while(count<parsedCSV.size()) {

usr=[select id,name,LastLoginDate, isactive, Username from User where Username= :parsedCSV.get(count)];
system.debug('_____________________'+usr);

for (User u : usr) {
lastlogin = u.LastLoginDate;
system.debug('@@@@@lastlogin' + lastlogin);
usrId = u.Id;
system.debug('@@@@@usrId' + usrId);
username = u.Username;
system.debug('@@@@@username'+ username);
isactive = u.isactive;
if(lastlogin==null && isactive == true) {

system.resetPassword(usrId, true);
}
}
}
}
}

Hello Guys,

 

I want to reset password and send an email for multiple users with no login history through apex. The code which I have written for even one user gives System.LimitException: DML currently not allowed. I am stuck on this issue for a while. Please help me out on this.

 

Apex code:

public class UserList{

public List<User> usr{get;set;}
public Datetime lastlogin;
public Id usrId;
public String username;
public UserList()
{
usr=[select id,name,LastLoginDate, Username from User where Username='xxx@rediffmail.com'];

for (User u : usr) {
lastlogin = u.LastLoginDate;
system.debug('@@@@@lastlogin' + lastlogin);
usrId = u.Id;
system.debug('@@@@@usrId' + usrId);
username = u.Username;
system.debug('@@@@@username'+ username);
if(lastlogin==null) {
system.resetPassword(usrId, true); //getting exception on this line, please help me out...!!


}

}
}

}

}

 

 

Hello!

 

We are in the professional services business, and we often work with organizations with multi-level hierarchies (3 to 4 levels is very average). I was wondering if anyone knows how one can create a script to automatically find out the ultimate parent of any account / contact / project, and store the result in a field on every entity.

 

this would allow us to create savvy rollups in our reporting and dashboarding. any help will be much appreciated.

 

thanks,

Pranav