• swatKat
  • NEWBIE
  • 205 Points
  • Member since 2013

  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 66
    Replies

Can someone please point out why I am not getting anything in the map if i search by Group Name ?

 

 

// Get Id of the Group named Finance_Team

 

Map<Id, Group> groupMap = new Map<Id, Group>([
    Select Id, Name
    From Group
    Where Name = 'Finance_Team'
]);

 

// The above query doesn't return me the id of the group

 

 

 

//Find all members of the group

List<GroupMember> groupMembers = [
    Select GroupId, UserOrGroupId
    From GroupMember
    Where GroupId In :groupMap.keySet()
];

 

put the id's of the group members in a set

Set<Id> userOrGroupIds = new Set<Id>();
for (GroupMember member : groupMembers) {
    userOrGroupIds.add(member.UserOrGroupId);
}

 

I think my trigger is not bulk safe.

 

Any help?

 

Trigger CriarTarefaCase_Solicitacao_Pagamento on Case (after insert, after update) {

Set<Id> hasTask = new Set<Id>();    
    Task[] tasks = new Task[0];
    
     for (Case c: Trigger.new) {
        Case oldCase = Trigger.oldMap.get(c.ID);
         
         for(Task tsk:[SELECT Id, whatid FROM Task WHERE subject = 'Solicitação de Pagamento - Lançar PP' AND whatid IN :Trigger.new])
        hasTask.add(tsk.whatid);
         
        if ((c.Quantas_PP_s_pagamento__c != oldCase.Quantas_PP_s_pagamento__c || c.Quantidade_de_PP_s_Estojo__c != oldCase.Quantidade_de_PP_s_Estojo__c || c.motivo_a__c != oldCase.motivo_a__c) && !hasTask.contains(c.Id)) {                  
                
            if ((c.Quantas_PP_s_pagamento__c > 0 || c.Quantidade_de_PP_s_Estojo__c > 0) && c.motivo_a__c != 'Cache'){
                if ((c.Quantas_PP_s_pagamento__c > 0 || c.Quantidade_de_PP_s_Estojo__c > 0) && c.motivo_a__c != 'Mostruarios'){
                    if ((c.Quantas_PP_s_pagamento__c > 0 || c.Quantidade_de_PP_s_Estojo__c > 0) && c.motivo_a__c != 'Laboratórios por fora do sistema'){
                        if ((c.Quantas_PP_s_pagamento__c > 0 || c.Quantidade_de_PP_s_Estojo__c > 0) && c.motivo_a__c != 'Devolução de venda'){
          Task tsk = new Task
              (whatID = c.ID,
               Solicita_o_de_Pagamento__c = c.motivo_a__c,
               Subject = 'Solicitação de Pagamento - Lançar PP',
               ActivityDate = Date.today(),
               Ownerid = '005U0000001KrZy');
    tasks.add(tsk);
                        }}}}}
    
    for(Task tsk:[SELECT Id, whatid FROM Task WHERE subject = 'Solicitação de Pagamento - Malote' AND whatid IN :Trigger.new])
        hasTask.add(tsk.whatid);
    
        if ((c.Forma_de_pagamento__c != oldCase.Forma_de_pagamento__c || c.motivo_a__c != oldCase.motivo_a__c) && !hasTask.contains(c.Id)) {
            
            if (c.Forma_de_pagamento__c == 'MALOTE' && c.motivo_a__c != 'Cache'){
                if (c.Forma_de_pagamento__c == 'MALOTE' && c.motivo_a__c != 'Mostruarios'){
                    if (c.Forma_de_pagamento__c == 'MALOTE' && c.motivo_a__c != 'Laboratórios por fora do sistema'){
                        if (c.Forma_de_pagamento__c == 'MALOTE' && c.motivo_a__c != 'Devolução de venda'){
          Task t = new Task
              (whatID = c.ID,
               Solicita_o_de_Pagamento__c = c.motivo_a__c,
               Subject = 'Solicitação de Pagamento - Malote',
               ActivityDate = Date.today(),
               Tarefa_de_fechamento__c = 'SIM',
               Ownerid = '005U0000001KrZy');
      tasks.add(t);
                        }}}}}
    }
insert tasks;
}

 Thanks!

Hi


I am creating tasks by trigger using code: Can anyone suggest ,How can I  create Tasks with a specific record type by trigger? using this code?

Task tsk = new Task(whatID = ID, Ownerid =user.id, Subject = 'XYZ', ActivityDate = DueDate.date() , IsReminderSet = true);
tasks.add(tsk);

How do I use the $User field in an if statement?

Something like:

case1=[Select Priority,CaseNumber,Accountid,Subject,Contactid,CreatedDate,Ownerid from case where Ownerid=!$User];  
     return case1;

 

which of course is not how to do it.

 

Thanks,

Haya

  • June 21, 2013
  • Like
  • 0

I have 2 extensions pulling data for 2 visualforce pages.

 

I am having a problem with one the fields showing different values.

 

1.

Extension code:

case1=[Select Priority,CaseNumber,Accountid,Subject,Contactid,CreatedDate,Ownerid from case];   
 return case1; 

 

vp code:

<apex:column value="{! s.Ownerid}" headerValue="Request Owner" />

 

Results: the Ownerid shows up as expected: General Queue

 

 

2. 

Extension code: 

case1=[Select Priority,CaseNumber,Accountid,Subject,Description,Contactid,Ownerid,CreatedDate from case where CaseNumber='00222854'];   
return case1;

 

vp code:

<p>{!s.Ownerid}</p>

 

Results: the Ownerid shows up as: 00G00000006pE82EAE

 

All the rest of the fields are displayed with the right values.

 

What am I doing wrong?

 

Thanks,

Haya

 

  • June 21, 2013
  • Like
  • 0

I am using remote action method to call the method from script.But its not working.

 

Here is my code:

 

VF page:

<apex:page controller="remotingController" sidebar="false" showHeader="false" standardStylesheets="false">
<apex:includescript value="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"/>

<script>
function Save(){
var textvalue = $('.texts').text();
remotingController.renameAlert(textvalue);
return false;
}
</script>

<apex:form >
<div class = "position">
<apex:outputLabel value="TextInput"></apex:outputLabel>
<apex:inputText styleclass = "texts" style="margin-left:30px;" />
<button onclick="Save();">Save </button>
</div>
</apex:form>
</apex:page>

 

Class:

global without sharing class remotingController  {
    public remotingController(){
    }
    
  @RemoteAction  
   global static void  renameAlert(string text){ 
       system.debug(':::::::text:::::::::::');
   }

}

 

 

Hi what I am trying to attain in my page is that I Have three comandbuttons "New Product", "Add Lot" , "Search Productt"

and when a user clicks on either of the buttons the related set of entities should be displayed.. Instead of re directing the user to a different page I want it to happen on this page itself.. I do not wish to use Iframe.. Is there any way?

 

Hello there,

 

I have a test method that is using following code:

 

01.    protected virtual HttpResponse executeLinkedInRequest(HttpRequest req)
02.    {
03.        HttpResponse res;
04.        res = new Http().send(req);
05.            
06.            if (req.getMethod() == 'POST' && res.getStatusCode() != 201)
07.            {
08.                System.debug('OAuth header:'+res.getHeader('oauth_problem'));
09.                throw new TwitterApiException (res.getBody());
10.            }
11.            else if (req.getMethod() == 'GET' && res.getStatusCode() != 200)
12.                throw new TwitterApiException (res.getBody());
13.        return res;
14.    }

 

When I am running the Test Class which contains this code, it is running till line number 04. Rest of the code comes in Red lines i.e. they are not getting executed. I know the root of the problem is HTTP().send(req) method. But, I am not able to understand why is that causing problem and how to make it work. Please help.

 

Thanks in advance.

Please help me ASAP to solve this scenario.

 

 I have one VF page on that we have a look up field  and Multiselect picklist. When ever user selects the lookup field from the custom object, automatically the corresponding picklist values should be updated. Here all are custom objects.

 

Please help me ASAP.

 

Regards,

kk

Can someone please point out why I am not getting anything in the map if i search by Group Name ?

 

 

// Get Id of the Group named Finance_Team

 

Map<Id, Group> groupMap = new Map<Id, Group>([
    Select Id, Name
    From Group
    Where Name = 'Finance_Team'
]);

 

// The above query doesn't return me the id of the group

 

 

 

//Find all members of the group

List<GroupMember> groupMembers = [
    Select GroupId, UserOrGroupId
    From GroupMember
    Where GroupId In :groupMap.keySet()
];

 

put the id's of the group members in a set

Set<Id> userOrGroupIds = new Set<Id>();
for (GroupMember member : groupMembers) {
    userOrGroupIds.add(member.UserOrGroupId);
}

 

Hi All ,

 

I am trying synchronize records from salesforce to saleforce and eveything wil be devloiped using apex.No java or c sharp.

 

Given below is the Wsdl to apex class.I am trying to use  login() api to connect to another salesforce org. I am trying it through anonymouse block.The login connection gets establised for the first time.However,I am at a total loss on how to retrieve  and assign retruned  URL and  session id .Below given is the code for login to the salesforce.How do i  create header and assign session id and server url to it so that I can call subsequent API's..Can somebody please help?

 

enterpriseSoapSforceCom.LoginResult lr=new enterpriseSoapSforceCom.LoginResult();
enterpriseSoapSforceCom.soap s=new enterpriseSoapSforceCom.soap();
lr=s.login('jack@yahoo.com','Password');

 

 

 

public class enterpriseSoapSforceCom {
    public class getUserInfo_element {
        private String[] apex_schema_type_info = new String[]{'urn:enterprise.soap.sforce.com','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class LoginResult {
        public String metadataServerUrl;
        public Boolean passwordExpired;
        public Boolean sandbox;
        public String serverUrl;
        public String sessionId;
        public String userId;
        public enterpriseSoapSforceCom.GetUserInfoResult userInfo;
        private String[] metadataServerUrl_type_info = new String[]{'metadataServerUrl','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] passwordExpired_type_info = new String[]{'passwordExpired','http://www.w3.org/2001/XMLSchema','boolean','1','1','false'};
        private String[] sandbox_type_info = new String[]{'sandbox','http://www.w3.org/2001/XMLSchema','boolean','1','1','false'};
        private String[] serverUrl_type_info = new String[]{'serverUrl','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] sessionId_type_info = new String[]{'sessionId','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] userId_type_info = new String[]{'userId','urn:enterprise.soap.sforce.com','ID','1','1','true'};
        private String[] userInfo_type_info = new String[]{'userInfo','urn:enterprise.soap.sforce.com','GetUserInfoResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:enterprise.soap.sforce.com','true','false'};
        private String[] field_order_type_info = new String[]{'metadataServerUrl','passwordExpired','sandbox','serverUrl','sessionId','userId','userInfo'};
    }
    
    public class Soap {
        public String endpoint_x = 'https://login.salesforce.com/services/Soap/c/28.0/0DFi0000000PCEo';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        public enterpriseSoapSforceCom.QueryOptions_element QueryOptions;
        public enterpriseSoapSforceCom.EmailHeader_element EmailHeader;
        public enterpriseSoapSforceCom.DebuggingInfo_element DebuggingInfo;
        public enterpriseSoapSforceCom.MruHeader_element MruHeader;
        public enterpriseSoapSforceCom.PackageVersionHeader_element PackageVersionHeader;
        public enterpriseSoapSforceCom.SessionHeader_element SessionHeader;
        public enterpriseSoapSforceCom.UserTerritoryDeleteHeader_element UserTerritoryDeleteHeader;
        public enterpriseSoapSforceCom.LoginScopeHeader_element LoginScopeHeader;
        public enterpriseSoapSforceCom.AllowFieldTruncationHeader_element AllowFieldTruncationHeader;
        public enterpriseSoapSforceCom.DebuggingHeader_element DebuggingHeader;
        public enterpriseSoapSforceCom.AllOrNoneHeader_element AllOrNoneHeader;
        public enterpriseSoapSforceCom.LocaleOptions_element LocaleOptions;
        public enterpriseSoapSforceCom.OwnerChangeOptions_element OwnerChangeOptions;
        public enterpriseSoapSforceCom.AssignmentRuleHeader_element AssignmentRuleHeader;
        public enterpriseSoapSforceCom.DisableFeedTrackingHeader_element DisableFeedTrackingHeader;
        public enterpriseSoapSforceCom.StreamingEnabledHeader_element StreamingEnabledHeader;
        private String QueryOptions_hns = 'QueryOptions=urn:enterprise.soap.sforce.com';
        private String EmailHeader_hns = 'EmailHeader=urn:enterprise.soap.sforce.com';
        private String DebuggingInfo_hns = 'DebuggingInfo=urn:enterprise.soap.sforce.com';
        private String MruHeader_hns = 'MruHeader=urn:enterprise.soap.sforce.com';
        private String PackageVersionHeader_hns = 'PackageVersionHeader=urn:enterprise.soap.sforce.com';
        private String SessionHeader_hns = 'SessionHeader=urn:enterprise.soap.sforce.com';
        private String UserTerritoryDeleteHeader_hns = 'UserTerritoryDeleteHeader=urn:enterprise.soap.sforce.com';
        private String LoginScopeHeader_hns = 'LoginScopeHeader=urn:enterprise.soap.sforce.com';
        private String AllowFieldTruncationHeader_hns = 'AllowFieldTruncationHeader=urn:enterprise.soap.sforce.com';
        private String DebuggingHeader_hns = 'DebuggingHeader=urn:enterprise.soap.sforce.com';
        private String AllOrNoneHeader_hns = 'AllOrNoneHeader=urn:enterprise.soap.sforce.com';
        private String LocaleOptions_hns = 'LocaleOptions=urn:enterprise.soap.sforce.com';
        private String OwnerChangeOptions_hns = 'OwnerChangeOptions=urn:enterprise.soap.sforce.com';
        private String AssignmentRuleHeader_hns = 'AssignmentRuleHeader=urn:enterprise.soap.sforce.com';
        private String DisableFeedTrackingHeader_hns = 'DisableFeedTrackingHeader=urn:enterprise.soap.sforce.com';
        private String StreamingEnabledHeader_hns = 'StreamingEnabledHeader=urn:enterprise.soap.sforce.com';
        private String[] ns_map_type_info = new String[]{'urn:fault.enterprise.soap.sforce.com', 'faultEnterpriseSoapSforceCom', 'urn:enterprise.soap.sforce.com', 'enterpriseSoapSforceCom', 'urn:sobject.enterprise.soap.sforce.com', 'sobjectEnterpriseSoapSforceCom'};
        public enterpriseSoapSforceCom.SearchResult search_x(String searchString) {
            enterpriseSoapSforceCom.search_element request_x = new enterpriseSoapSforceCom.search_element();
            enterpriseSoapSforceCom.searchResponse_element response_x;
            request_x.searchString = searchString;
            Map<String, enterpriseSoapSforceCom.searchResponse_element> response_map_x = new Map<String, enterpriseSoapSforceCom.searchResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'urn:enterprise.soap.sforce.com',
              'search',
              'urn:enterprise.soap.sforce.com',
              'searchResponse',
              'enterpriseSoapSforceCom.searchResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.result;
        
            public enterpriseSoapSforceCom.LoginResult login(String username,String password) {
            enterpriseSoapSforceCom.login_element request_x = new enterpriseSoapSforceCom.login_element();
            enterpriseSoapSforceCom.loginResponse_element response_x;
            request_x.username = username;
            request_x.password = password;
            Map<String, enterpriseSoapSforceCom.loginResponse_element> response_map_x = new Map<String, enterpriseSoapSforceCom.loginResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'urn:enterprise.soap.sforce.com',
              'login',
              'urn:enterprise.soap.sforce.com',
              'loginResponse',
              'enterpriseSoapSforceCom.loginResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.result;
        }
            
            
        }
        
        
        }

How do I restrict the user not to delete Notes and Attachment records from any Standard or Custom object?

Hi,

 

I'm working on my first trigger and test, and I think I got through most of the problems in the code, but I keep failing to validate them. In the developer console it tells me that the trigger has a 100% on all tests,but as you can see, this is not how the program reads it when validating.

 

Attached are the fails I get, and the modified code:

 

TestDontDelete.myUnitTest() - Failure Message: "System.QueryException: List has more than 1 row for assignment to SObject", Failure Stack Trace: "Class.TestDontDelete.myUnitTest: line 7, column 1"
 
dontDelete - Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required.
 
Deploy Error - Average test coverage across all Apex Classes and Triggers is 0%, at least 75% test coverage is required.

 

Trigger:

 

//Prevent deleting a contact that is associated with a 203k disbursement

trigger dontDelete on Contact (before delete)
{
  RecordType r =[Select id, name from RecordType where SobjectType='Contact' and name='Contractor'];
  for (Contact x : Trigger.old)
  {
    if (x.RecordTypeId==r.id)
    {
      x.addError('You cannot delete this an account of type "Contractor"');
    }
  }
}

 

Test:

 

@isTest
private class TestDontDelete
{
  static testMethod void myUnitTest()
  {

    Contact con = new Contact (LastName = 'Testi', RecordTypeID= [SELECT Id FROM RecordType WHERE Name = 'Contractor'].Id);

    try
    {
      delete con;
    }
  catch (dmlexception e)
  {
    system.assert(e.getMessage().contains('You cannot delete this an account of type "Contractor"'),
    e.getMessage());
  }
}
}

  • July 01, 2013
  • Like
  • 0

I'm having an issue with a very tricky custom URL – I want to create a custom list button on the Solution related list in the Case object that allows the user to create a new solution, then associate that solution with the present case and return to the case record.

 

So far I have:

 

/501/e?&saveURL=%2F{!Case.Id}?a_case_soln={!Solution.Id}&retURL=%2F{!Case.Id}

I think my issue is that the solution ID is not created yet when I hit the button and thus the system does not know how to associate my new solution to the case… any suggestions on getting this to work?

Hi,

 

I am not a developer and it's hard for me to create even a simple Apex code.

Can somebody post a simple APEX trigger to update lookup field based on the picklist value field.

What I am looking for is to update:

Campaign Source (custom lookup field on opportunity) to a specific campaign name "Marketing Campaign" if lead source field (picklist ) is "Marketing Lead".

Thank you

Hi, 

 

Can any one send the steps how to
"convert lookup reationship field to master detail realtionship"

I think my trigger is not bulk safe.

 

Any help?

 

Trigger CriarTarefaCase_Solicitacao_Pagamento on Case (after insert, after update) {

Set<Id> hasTask = new Set<Id>();    
    Task[] tasks = new Task[0];
    
     for (Case c: Trigger.new) {
        Case oldCase = Trigger.oldMap.get(c.ID);
         
         for(Task tsk:[SELECT Id, whatid FROM Task WHERE subject = 'Solicitação de Pagamento - Lançar PP' AND whatid IN :Trigger.new])
        hasTask.add(tsk.whatid);
         
        if ((c.Quantas_PP_s_pagamento__c != oldCase.Quantas_PP_s_pagamento__c || c.Quantidade_de_PP_s_Estojo__c != oldCase.Quantidade_de_PP_s_Estojo__c || c.motivo_a__c != oldCase.motivo_a__c) && !hasTask.contains(c.Id)) {                  
                
            if ((c.Quantas_PP_s_pagamento__c > 0 || c.Quantidade_de_PP_s_Estojo__c > 0) && c.motivo_a__c != 'Cache'){
                if ((c.Quantas_PP_s_pagamento__c > 0 || c.Quantidade_de_PP_s_Estojo__c > 0) && c.motivo_a__c != 'Mostruarios'){
                    if ((c.Quantas_PP_s_pagamento__c > 0 || c.Quantidade_de_PP_s_Estojo__c > 0) && c.motivo_a__c != 'Laboratórios por fora do sistema'){
                        if ((c.Quantas_PP_s_pagamento__c > 0 || c.Quantidade_de_PP_s_Estojo__c > 0) && c.motivo_a__c != 'Devolução de venda'){
          Task tsk = new Task
              (whatID = c.ID,
               Solicita_o_de_Pagamento__c = c.motivo_a__c,
               Subject = 'Solicitação de Pagamento - Lançar PP',
               ActivityDate = Date.today(),
               Ownerid = '005U0000001KrZy');
    tasks.add(tsk);
                        }}}}}
    
    for(Task tsk:[SELECT Id, whatid FROM Task WHERE subject = 'Solicitação de Pagamento - Malote' AND whatid IN :Trigger.new])
        hasTask.add(tsk.whatid);
    
        if ((c.Forma_de_pagamento__c != oldCase.Forma_de_pagamento__c || c.motivo_a__c != oldCase.motivo_a__c) && !hasTask.contains(c.Id)) {
            
            if (c.Forma_de_pagamento__c == 'MALOTE' && c.motivo_a__c != 'Cache'){
                if (c.Forma_de_pagamento__c == 'MALOTE' && c.motivo_a__c != 'Mostruarios'){
                    if (c.Forma_de_pagamento__c == 'MALOTE' && c.motivo_a__c != 'Laboratórios por fora do sistema'){
                        if (c.Forma_de_pagamento__c == 'MALOTE' && c.motivo_a__c != 'Devolução de venda'){
          Task t = new Task
              (whatID = c.ID,
               Solicita_o_de_Pagamento__c = c.motivo_a__c,
               Subject = 'Solicitação de Pagamento - Malote',
               ActivityDate = Date.today(),
               Tarefa_de_fechamento__c = 'SIM',
               Ownerid = '005U0000001KrZy');
      tasks.add(t);
                        }}}}}
    }
insert tasks;
}

 Thanks!