• manuel-jose-conde
  • NEWBIE
  • 155 Points
  • Member since 2010

  • Chatter
    Feed
  • 6
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 30
    Replies
public with sharing class ServiceClass 
{
     public static Map<String, RecordType> CaseRecordTypesNameMap
    {
        get
        {
            if(CaseRecordTypesNameMap == null){
                CaseRecordTypesNameMap = new Map<String,RecordType>();
                for(RecordType rt: [Select Id, Name from RecordType where sObjectType = 'Case' ])
                CaseRecordTypesNameMap.put(rt.Name, rt);
            }
            return CaseRecordTypesNameMap;

        }
        
        private set;
    }

     public static Map<String, RecordType> TaskRecordTypesNameMap
    {
        get
        {
            if(TaskRecordTypesNameMap == null){
                TaskRecordTypesNameMap = new Map<String,RecordType>();
                for(RecordType rt: [Select Id, Name from RecordType where sObjectType = 'Task' ])
                TaskRecordTypesNameMap.put(rt.Name, rt);
            }
            return TaskRecordTypesNameMap;

        }
        
        private set;
    }
}

 What I would like to do is take these two functions and make them so they would work with any sObjectType in the system, by passing the sObjectType = variable passed from class call the ServiceClass above.

 

Secondly, a little suggestion on how to call the class with the two parameters?

 

Thank you,

Steve Laycock

Hi All

 

I amtrying to insert a value  in a custom object field  whenever user hits the tab in visualforce page. As well i am trying to pull the user information who clciked the tab. When i checked the debuglogs it is entering in to the loop and throwing the DML currently not allowed Error. What should i need to do inorder to insert a value. Appreciate your help 

 

Here is the part of the vf page

 <apex:tab label="Credit History" id="BTNtabSix" onclick="Callcon('Credithistory');" style="background-color: white;" >

<apex:actionFunction name="callCon" oncomplete="callCon1();">
<apex:param name="firstParam" value="" assignTo="{!Tabselected}"/>
</apex:actionFunction>
<apex:actionfunction name="callCon1" action="{!searchtab}"/>

</apex:tab>

 

Here is my part of my controller. I called the searchtab method in one of the void method

public with sharing class SummaryPageController {

public used_tab__c Tab; //sreekanth
public List<tools_of_users__c> uList;
public String Tabselected {get;set;}
Integer cnt;

 public void objCustomerAccountInfo(){

 

lstCreditHistory = [SELECT Account_DOB__c,Account_Id__c from FROM Credit_History__c WHERE Account_Id__c =:strAccId  LIMIT 999];
if(lstCreditHistory.size()>0) objCreditHistory = lstCreditHistory[0];
searchtab();

}

Public PageReference searchtab() {

Tab = new used_tab__c(); //sreekanth
uList = new List<tools_of_users__c>();

if(Tabselected != null && Tabselected != '') {

system.debug('###### '+Tabselected);
Tab.tab_used__c ='Tabselected';
}

system.debug('###### '+Tab.tab_used__c);
cnt = [SELECT COUNT() FROM tools_of_users__c WHERE User_Record_Id__c = :Userinfo.getUserId()];

if(cnt == 0) //not existing yet
{
ulist.add(new tools_of_users__c(User_Record_Id__c = Userinfo.getUserId()));
try{
Database.SaveResult saveResult = Database.Insert(uList[0], false);

System.debug('************* New List_of_User__c Id: ' + saveResult.getId());

Tab.users__c = saveResult.getId();
insert Tab;


}catch(System.DMLException de){
System.debug('************insert of new tools used to NEW user FAILED:'+'\n'+ de.getMessage());
}

}else{
//get the current user record Id
uList= [SELECT Id, User_Record_Id__c FROM tools_of_users__c WHERE User_Record_Id__c = :Userinfo.getUserId()];
Tab.users__c = uList[0].Id;

try{
insert Tab;
//update uList[0];
system.debug('################### '+Tab.Id);

}catch(System.DMLException de){
System.debug('************insert of new tools used to EXISTING user FAILED: '+'\n'+ de.getMessage());
}
}
return null;
}
}

 

In my Apex code I want to log about the ID with no finformation about the corresponding SObject. How can I find what is the SObject for a given external Id?

  • November 28, 2012
  • Like
  • 0

I'm hoping someone can help. I'm writing a test class for a simple Line Item trigger (totally new at this). I am getting an error that the PriceBookEntryId can't be blank, but every time I try to pull in an ID, I get the error that my query returned no rows. 

 

Original trigger:

 

1
2
3
4

trigger OpportunityLineItemBeforeDelete on OpportunityLineItem (before delete) {
for (OpportunityLineItem li: Trigger.old)
    li.addError('Cannot remove a property once added. Contact support');
}

 

 

Test class that gives me the error: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: PricebookEntryId, unknown (versions 3.0 and higher must specify pricebook entry id; others must specify product id): [PricebookEntryId, unknown]

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@IsTest
public class LIDeleteClass{
    static TestMethod void InsertOppty()
    {Date myDate = date.newinstance(2014, 12, 17);
    Opportunity oppty = new Opportunity(Name='Test', StageName='IO Signed', CloseDate=myDate);
      insert oppty;
    Opportunity oppty1 = [select id, Name, Stagename, Closedate 
                          from Opportunity 
                          where Name = :'Test' LIMIT 1];

     //PricebookEntry pbe = [select Id 
       //                    from PricebookEntry
         //                  where Product2.Name = :'Amazon Ad Platform (AAP)' 
     
            //               and Pricebook2.Name = :'Standard Price Book' LIMIT 1];
    OpportunityLineItem li = new OpportunityLineItem(OpportunityId=oppty1.id, Quantity=12000,TotalPrice=12000);

      insert li;
    Test.starttest();
       try
           {
              delete li;
            
              System.assert(false);
           }
           catch (DMLException e)
           {
          
           }
    Test.stoptest();
    }}

 

When I uncomment the pbe variable, I get the error System.QueryException: List has no rows for assignment to SObject.

 

Any help would be appreciated.

I have a typical deployment scenario at my work place.
 
We have Perforce for Version control.
 
Here is the scenario:
 
A developer codes, customize or configure something in his dev org. He now checks in his changes to the version control repository called Perforce.
 
I have to do a automated deployment every night to query perforce for the latest changelist/Label dynamically and then deploy the changes to sandbox, prod etc. This one should be automated with no human interventions. Again this whole process of querying and then deploying should be automated. While querying i should be querying only the changed files based on a label or changelist and not all the files.
 
is there a way to handle this scenario and is there any reference for me to accomplish this?
 
 
Another question,
 
I have a folder that contains subfolders like objects, classes etc. can i do deployment using Ant migration tool without the package.xml file in it
Is the package.xml file really needed for any kind deployment.
 
This is a very critical req that has to be answered before noon. Please help me da.

I am working on a VF page to display Account contacts in the Opportunity.  Within my class I have written a SOQL query to pull these contacts, but for some reason I can't reference the Opportunity.AccountID.  Within my query I am simply stating:

 

[select id, AccountID, FirstName, LastName, Phone, Email, Question_Answer__c, Role__c, Secondary_Role__c,Tertiary_Role__c, Create_Profile__c from Contact Where AccountID = :ApexPages.currentPage().getParameters().get('AccountID') ORDER BY LastName];

 

When I debug, the AccountID is passing as a null value.  

 

Any suggestions on how I can gather the Opportunity AccountID and use it within my select statement?

Hi,

do you know if an approval is automaticaly submited during a user provisioning request? 
My efforts so far show that it isn't. I see also in the documentation the following: From the User Provisioning Requests tab, you can view details and manage approvals for an individual user provisioning request.

https://help.salesforce.com/articleView?id=connected_app_user_provisioning_manage.htm&language=en_US&type=0

For me, It does not make sense  that users need to go in each record user prov request to click submit... 

 

how can we retrieve in a SOQL statement the currency name? (not the isoCode)

Hi,

 

I'm using DescribeSObjectResult to retrieve details about Object and its fields.

I noted that the Description property of each field is not available. 

 

I see here

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_describesobjects_describesobjectresult.htm#i1427375

 

Am I missing anything here?

 

What's the reason for not having the description available in API?

 

Thanks

Manuel

I want to change a field from Lookup to Master-Detail data type.  When I make the change in a sandbox, the sharing model for the child object changes to 'Controlled by Parent' automatically.  If I try and deploy the change to another sandbox (eclipse), it fails saying I can't change the sharing model through the API.  Any suggestions?

  • December 18, 2012
  • Like
  • 0

Hi guys!

 

I need some advice on wether I should be learning / writing an APEX trigger, or wether a custom button would be better for my application.

 

I have the 'Cases' Related List in my Opportunities Section. My Cases object has 3x Record Types (New Warranty Service, New Installation Service & New Maintenance Service)

 

Under My Opportunity, I want to have the three buttons on the cases related list (New Warranty Service, New Installation Service & New Maintenance Service). Once they are clicked, I need different information from the opportunity to populate each different record type.

 

Am I best to use a custom button and 'URL HACK' it to populate these field, or should I look into writing an APEX tigger to 'future proof' my SFDC instance? I have been told that the 'URL HACK' is really just a temporary fix if SFDC decide to update field names etc, they will break.

 

Thanks in advance for the help!

 

Jimmy.

public with sharing class ServiceClass 
{
     public static Map<String, RecordType> CaseRecordTypesNameMap
    {
        get
        {
            if(CaseRecordTypesNameMap == null){
                CaseRecordTypesNameMap = new Map<String,RecordType>();
                for(RecordType rt: [Select Id, Name from RecordType where sObjectType = 'Case' ])
                CaseRecordTypesNameMap.put(rt.Name, rt);
            }
            return CaseRecordTypesNameMap;

        }
        
        private set;
    }

     public static Map<String, RecordType> TaskRecordTypesNameMap
    {
        get
        {
            if(TaskRecordTypesNameMap == null){
                TaskRecordTypesNameMap = new Map<String,RecordType>();
                for(RecordType rt: [Select Id, Name from RecordType where sObjectType = 'Task' ])
                TaskRecordTypesNameMap.put(rt.Name, rt);
            }
            return TaskRecordTypesNameMap;

        }
        
        private set;
    }
}

 What I would like to do is take these two functions and make them so they would work with any sObjectType in the system, by passing the sObjectType = variable passed from class call the ServiceClass above.

 

Secondly, a little suggestion on how to call the class with the two parameters?

 

Thank you,

Steve Laycock

Hi All

 

I amtrying to insert a value  in a custom object field  whenever user hits the tab in visualforce page. As well i am trying to pull the user information who clciked the tab. When i checked the debuglogs it is entering in to the loop and throwing the DML currently not allowed Error. What should i need to do inorder to insert a value. Appreciate your help 

 

Here is the part of the vf page

 <apex:tab label="Credit History" id="BTNtabSix" onclick="Callcon('Credithistory');" style="background-color: white;" >

<apex:actionFunction name="callCon" oncomplete="callCon1();">
<apex:param name="firstParam" value="" assignTo="{!Tabselected}"/>
</apex:actionFunction>
<apex:actionfunction name="callCon1" action="{!searchtab}"/>

</apex:tab>

 

Here is my part of my controller. I called the searchtab method in one of the void method

public with sharing class SummaryPageController {

public used_tab__c Tab; //sreekanth
public List<tools_of_users__c> uList;
public String Tabselected {get;set;}
Integer cnt;

 public void objCustomerAccountInfo(){

 

lstCreditHistory = [SELECT Account_DOB__c,Account_Id__c from FROM Credit_History__c WHERE Account_Id__c =:strAccId  LIMIT 999];
if(lstCreditHistory.size()>0) objCreditHistory = lstCreditHistory[0];
searchtab();

}

Public PageReference searchtab() {

Tab = new used_tab__c(); //sreekanth
uList = new List<tools_of_users__c>();

if(Tabselected != null && Tabselected != '') {

system.debug('###### '+Tabselected);
Tab.tab_used__c ='Tabselected';
}

system.debug('###### '+Tab.tab_used__c);
cnt = [SELECT COUNT() FROM tools_of_users__c WHERE User_Record_Id__c = :Userinfo.getUserId()];

if(cnt == 0) //not existing yet
{
ulist.add(new tools_of_users__c(User_Record_Id__c = Userinfo.getUserId()));
try{
Database.SaveResult saveResult = Database.Insert(uList[0], false);

System.debug('************* New List_of_User__c Id: ' + saveResult.getId());

Tab.users__c = saveResult.getId();
insert Tab;


}catch(System.DMLException de){
System.debug('************insert of new tools used to NEW user FAILED:'+'\n'+ de.getMessage());
}

}else{
//get the current user record Id
uList= [SELECT Id, User_Record_Id__c FROM tools_of_users__c WHERE User_Record_Id__c = :Userinfo.getUserId()];
Tab.users__c = uList[0].Id;

try{
insert Tab;
//update uList[0];
system.debug('################### '+Tab.Id);

}catch(System.DMLException de){
System.debug('************insert of new tools used to EXISTING user FAILED: '+'\n'+ de.getMessage());
}
}
return null;
}
}

 

In my Apex code I want to log about the ID with no finformation about the corresponding SObject. How can I find what is the SObject for a given external Id?

  • November 28, 2012
  • Like
  • 0

I'm hoping someone can help. I'm writing a test class for a simple Line Item trigger (totally new at this). I am getting an error that the PriceBookEntryId can't be blank, but every time I try to pull in an ID, I get the error that my query returned no rows. 

 

Original trigger:

 

1
2
3
4

trigger OpportunityLineItemBeforeDelete on OpportunityLineItem (before delete) {
for (OpportunityLineItem li: Trigger.old)
    li.addError('Cannot remove a property once added. Contact support');
}

 

 

Test class that gives me the error: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: PricebookEntryId, unknown (versions 3.0 and higher must specify pricebook entry id; others must specify product id): [PricebookEntryId, unknown]

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@IsTest
public class LIDeleteClass{
    static TestMethod void InsertOppty()
    {Date myDate = date.newinstance(2014, 12, 17);
    Opportunity oppty = new Opportunity(Name='Test', StageName='IO Signed', CloseDate=myDate);
      insert oppty;
    Opportunity oppty1 = [select id, Name, Stagename, Closedate 
                          from Opportunity 
                          where Name = :'Test' LIMIT 1];

     //PricebookEntry pbe = [select Id 
       //                    from PricebookEntry
         //                  where Product2.Name = :'Amazon Ad Platform (AAP)' 
     
            //               and Pricebook2.Name = :'Standard Price Book' LIMIT 1];
    OpportunityLineItem li = new OpportunityLineItem(OpportunityId=oppty1.id, Quantity=12000,TotalPrice=12000);

      insert li;
    Test.starttest();
       try
           {
              delete li;
            
              System.assert(false);
           }
           catch (DMLException e)
           {
          
           }
    Test.stoptest();
    }}

 

When I uncomment the pbe variable, I get the error System.QueryException: List has no rows for assignment to SObject.

 

Any help would be appreciated.

Please suggest me how to send chatter notifications as mail like workflow email alert. I have this requirement.Please give ideas on this ASAP

  • November 11, 2012
  • Like
  • 0

I created a custom field at the opportunity product level called "Year 1 summary". It's a number calculated off other things. Can't seem to get it to appear in the Aggregate Picklist when I create a Roll Up Summary field at the opportunity level.

 

Any Advice would be appreciated.

 

 

Hi folks,

 

     I am trying to divide the records in an object  on monthly base , is it possible .

 

 please help.

  • November 02, 2012
  • Like
  • 0
I have a typical deployment scenario at my work place.
 
We have Perforce for Version control.
 
Here is the scenario:
 
A developer codes, customize or configure something in his dev org. He now checks in his changes to the version control repository called Perforce.
 
I have to do a automated deployment every night to query perforce for the latest changelist/Label dynamically and then deploy the changes to sandbox, prod etc. This one should be automated with no human interventions. Again this whole process of querying and then deploying should be automated. While querying i should be querying only the changed files based on a label or changelist and not all the files.
 
is there a way to handle this scenario and is there any reference for me to accomplish this?
 
 
Another question,
 
I have a folder that contains subfolders like objects, classes etc. can i do deployment using Ant migration tool without the package.xml file in it
Is the package.xml file really needed for any kind deployment.
 
This is a very critical req that has to be answered before noon. Please help me da.

Can I create multiple domain in Force.Com Sites

 

Like :-

 

www.abc.com

 

and

 

www.xyz.com