• Gopikrishnan Nedumparambumana
  • NEWBIE
  • 15 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 5
    Replies
Hi,
I have an issue with attaching files to a custom object that we created. The file attachment is part of the default related files we have in salesfore. The issue happens with there are multiple dots (.) in the filename.

In that case, it throws an error saying "Error in filename". Noticed this when there are more than 3 dots in the filename other than extension part.

Is this a limit on Salesforce? How do resolve it?

Sample PDF filename with issue : S32290_Rel.Qual.Report_rev1.asdasd.pdf
Hello,

I am trying to display content from a JSON feed on my Salesforce page using APEX/visualforce page. From information gathered, I am able to get the details of the JSON on variable. But when running the visualforce page, I get the below error. Any help much appreciated..

Apex Code 
global class loraGeneralEventsController {

	public String title{get;set;}
	public String link{get;set;}
	public String event_date{get;set;}
	public location location{get;set;}
	public List<Items> dr{get;set;}

	public loraGeneralEventsController(){

	}

	public void requestM(){

		String url = 'https://www.semtech.com/company/events-json/lora-general-event';

		HttpRequest req = new HttpRequest();
		req.setEndpoint(url);
		req.setMethod('GET');

		Http http = new Http();
		HttpResponse res = http.send(req);
		String responseBody = res.getBody();
		system.debug('JSON Content : ' + responseBody);
		
		ResCls resItem = (ResCls)JSON.deserialize(responseBody, ResCls.class);
		List<Items> rl = resItem.items;
		system.debug('Item List : ' + resItem.items);
		dr = new List<Items>();
		for(Items it:rl){
			system.debug('Item Name: ' + it);
			title = it.title;
			link = it.link;
			system.debug('event_date: ' + it.event_date);
			system.debug('location: ' + it.location);
			dr.add(it);
		}   
	   system.debug('List: ' + dr);
	}

	public class ResCls{
		List<Items> items;
	}
		
	public class Items{

		public String title {get;set;}
		public String link {get;set;}
		public String event_date {get;set;}
		public String description {get;set;}
		public String location {get;set;}
		public String categories {get;set;}
		public String pubdate {get;set;}
	}


}

Visual force page :
<apex:page Controller="loraGeneralEventsController" action="{!requestM}" sidebar="false">
    <apex:pageBlock>
        <apex:pageblockSection >
            <apex:pageblockTable value="{!dr}" var="dd">
                    <apex:column headerValue="Title"><apex:outputText value="{!dd.title}"/></apex:column>
                    <apex:column headerValue="URL"><apex:outputText value="{!dd.link}"/></apex:column>
                    <apex:column headerValue="Date"><apex:outputText value="{!dd.event_date}"/></apex:column>
                    <apex:column headerValue="Location"><apex:outputText value="{!dd.location}"/></apex:column>
            </apex:pageblockTable>
        </apex:pageblockSection>
    </apex:pageBlock>
</apex:page>

Error that I get when runnig the page is 
 
Attempt to de-reference a null object
Error is in expression '{!requestM}' in component <apex:page> in page lorageneralevents: Class.loraGeneralEventsController.requestM: line 30, column 1

An unexpected error has occurred. Your development organization has been notified.

 

 
I do have an issue with sharing a contact with partner users. The objective of the trigger is that, if a partner tries to create a contact in our system and if the email he uses to create the new contact is already in a contact, then share that existing contact with the partner rather than creating new contact.
Below is trigger that I used.
 
trigger checkContactExists on Contact(before insert) {
    String us = userinfo.getUserType();
    String emailValue = '';
    List<ContactShare> sharesToCreate = new List<ContactShare>();

    if(us == 'PowerPartner' || us == 'CSPLitePortal' || us == 'CustomerSuccess' || us == 'PowerCustomerSuccess') {
        for(Contact c: Trigger.New){
            emailValue = c.Email;           
            list<contact> contact1 = [SELECT Id FROM contact WHERE Email =:emailValue];
            if(contact1.size()>0) {
                for (Contact cont :contact1){
                    Contactshare cs = new ContactShare(ContactAccessLevel='Read', ContactId = cont.Id, userOrGroupId = UserInfo.getUserId());
                    sharesToCreate.add(cs);   
                }
            }
            c.addError('Duplicate contact found with the same email. The existing contact has been shared with you.');
        }

    }
     if (!sharesToCreate.isEmpty()) {
        //Database.SaveResult[] insertResults = Database.insert(sharesToCreate,true);
        insert sharesToCreate;
    }
}

The code doesn't shows any error and debug log says it created a row on contactsshare.
 
:57:25.0 (49336464)|STATEMENT_EXECUTE|[20]
16:57:25.0 (49337911)|STATEMENT_EXECUTE|[22]
16:57:25.0 (49400693)|DML_BEGIN|[22]|Op:Insert|Type:ContactShare|Rows:1
16:57:25.0 (49430731)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
16:57:25.0 (94617974)|DML_END|[22]

But when looking into the SOQL, I don't see any new rows of data being added. Any help appreciated.






 
Hello,

I have a an field on a custom object that is of type loopup. I want to change the lookup to another object. From what I understand, the only option is to create a new field pointing to the new object and rename it. But I do have many triggers, classes, relationship that is associated with the old field and want to change that too. I do like to keep the old field and rename to field__old__c and rename the new one as field__c  which is the name of current existing field.
But due to those triggers and other relationship having on the existing field, I am having lot of cyclic reference issues. Is there a way to overcome this? What is the general rule to manage these type of changes and move to production?
Hi,
We have two communites dedicated for two seperate purpose and lots of knowledge articles in each of them.
When I type something like "What is adaptive" on our community 1, and see recommended articles. It is showing suggetions from other communities what we have. And each articles are assigned on seperate type and category. And we have limited each category to display based on category assigned to it. Still content search on default Salesforce chatter shows content from other. Any idea how to resolve it.
On my test class, I am getting the following error.
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Chatter Answers User is not allowed for this License Type.: [UserPermissions] 
Stack Trace: Class.ChatterAnswersAuthProviderRegTest.validateCreateUpdateUser: line 32, column 1


The class that does it is

@isTest
private class ChatterAnswersAuthProviderRegTest {
  static testMethod void validateCreateUpdateUser() {
    User thisUser = [ select Id from User where Id = :UserInfo.getUserId() ];
    System.runAs ( thisUser ) {
      Auth.UserData userData = new Auth.UserData('testId', 'testFirst', 'testLast',
      'testFirst testLast', 'no-reply@salesforce.com', null, 'testuserlong', 'en_US', 'facebook',
      null, new Map<String, String>{'language' => 'en_US'});
      ChatterAnswersAuthProviderRegistration reg = new ChatterAnswersAuthProviderRegistration();
      Profile[] p = [SELECT Id FROM Profile WHERE Name = 'System Administrator'];
      User[] adminUser = [SELECT Id, Firstname, Lastname FROM User WHERE IsActive = true and ProfileId =: p[0].Id LIMIT 1];
      reg.setSiteAdminUserId(adminUser[0].Id);
      User newUser = reg.createUser(null, userData);
      System.assert(newUser != null, 'A new user should have been created');
      System.assertEquals(newUser.Firstname, 'testFirst', 'First name should have been same');
      System.assertEquals(newUser.Lastname, 'testLast', 'Last name should have been same');
      System.assertEquals(newUser.Email, 'no-reply@salesforce.com', 'Email should have been same');
      
      Contact c = new Contact();
      c.AccountId = (newUser.Username.split('@'))[0];
      c.LastName = 'contactLast';
      insert(c);
      
      newUser.profileId = p[0].Id;
      newUser.Alias = 'firstusr';
      newUser.TimeZoneSidKey = 'America/Los_Angeles';
      newUser.LocaleSidKey = 'en_US';
      newUser.EmailEncodingKey = 'UTF-8';
      newUser.LanguageLocaleKey = 'en_US';
      newUser.ContactId = c.Id;
      
      insert(newUser);
      
      
      Auth.UserData updateUserData = new Auth.UserData('testId', 'updatedFirst', 'updatedLast',
      'updatedFirst updatedLast', 'no-reply@new.salesforce.com', null, 'testuserlong', 'en_US', 'facebook',
      null, new Map<String, String>{'language' => 'en_US'});
      reg.updateUser(newUser.Id, null, updateUserData);
      
      User dbUser =  [SELECT Id, Firstname, Lastname, Email FROM User WHERE Id = :newUser.Id];
      System.assertEquals(dbUser.Firstname, 'updatedFirst', 'First name should have been updated');
      System.assertEquals(dbUser.Lastname, 'updatedLast', 'Last name should have been updated');
      System.assertEquals(dbUser.Email, 'no-reply@new.salesforce.com', 'Email should have been updated');
    }
  }
}


I think this is related to some permission with the profile "System Administrator".  Any idea which permission needs to be enabled the user?
 
Hello,

I have a an field on a custom object that is of type loopup. I want to change the lookup to another object. From what I understand, the only option is to create a new field pointing to the new object and rename it. But I do have many triggers, classes, relationship that is associated with the old field and want to change that too. I do like to keep the old field and rename to field__old__c and rename the new one as field__c  which is the name of current existing field.
But due to those triggers and other relationship having on the existing field, I am having lot of cyclic reference issues. Is there a way to overcome this? What is the general rule to manage these type of changes and move to production?
On my test class, I am getting the following error.
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Chatter Answers User is not allowed for this License Type.: [UserPermissions] 
Stack Trace: Class.ChatterAnswersAuthProviderRegTest.validateCreateUpdateUser: line 32, column 1


The class that does it is

@isTest
private class ChatterAnswersAuthProviderRegTest {
  static testMethod void validateCreateUpdateUser() {
    User thisUser = [ select Id from User where Id = :UserInfo.getUserId() ];
    System.runAs ( thisUser ) {
      Auth.UserData userData = new Auth.UserData('testId', 'testFirst', 'testLast',
      'testFirst testLast', 'no-reply@salesforce.com', null, 'testuserlong', 'en_US', 'facebook',
      null, new Map<String, String>{'language' => 'en_US'});
      ChatterAnswersAuthProviderRegistration reg = new ChatterAnswersAuthProviderRegistration();
      Profile[] p = [SELECT Id FROM Profile WHERE Name = 'System Administrator'];
      User[] adminUser = [SELECT Id, Firstname, Lastname FROM User WHERE IsActive = true and ProfileId =: p[0].Id LIMIT 1];
      reg.setSiteAdminUserId(adminUser[0].Id);
      User newUser = reg.createUser(null, userData);
      System.assert(newUser != null, 'A new user should have been created');
      System.assertEquals(newUser.Firstname, 'testFirst', 'First name should have been same');
      System.assertEquals(newUser.Lastname, 'testLast', 'Last name should have been same');
      System.assertEquals(newUser.Email, 'no-reply@salesforce.com', 'Email should have been same');
      
      Contact c = new Contact();
      c.AccountId = (newUser.Username.split('@'))[0];
      c.LastName = 'contactLast';
      insert(c);
      
      newUser.profileId = p[0].Id;
      newUser.Alias = 'firstusr';
      newUser.TimeZoneSidKey = 'America/Los_Angeles';
      newUser.LocaleSidKey = 'en_US';
      newUser.EmailEncodingKey = 'UTF-8';
      newUser.LanguageLocaleKey = 'en_US';
      newUser.ContactId = c.Id;
      
      insert(newUser);
      
      
      Auth.UserData updateUserData = new Auth.UserData('testId', 'updatedFirst', 'updatedLast',
      'updatedFirst updatedLast', 'no-reply@new.salesforce.com', null, 'testuserlong', 'en_US', 'facebook',
      null, new Map<String, String>{'language' => 'en_US'});
      reg.updateUser(newUser.Id, null, updateUserData);
      
      User dbUser =  [SELECT Id, Firstname, Lastname, Email FROM User WHERE Id = :newUser.Id];
      System.assertEquals(dbUser.Firstname, 'updatedFirst', 'First name should have been updated');
      System.assertEquals(dbUser.Lastname, 'updatedLast', 'Last name should have been updated');
      System.assertEquals(dbUser.Email, 'no-reply@new.salesforce.com', 'Email should have been updated');
    }
  }
}


I think this is related to some permission with the profile "System Administrator".  Any idea which permission needs to be enabled the user?