• Nitin Palmure 5
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 10
    Replies
I am trying to create a VF page where user can search for a record based on id field and edit it on the same page.
I have searched and found almost all the solutions which displays values in Tablular form.
I want to display the results in a Form fields itself and enable users to make changes and save.

Can anyone suggest on this ?

Thank you.
I am executing following code as execute anonymous
Competition__c Member = [SELECT Team_Members__c FROM Competition__c WHERE Id =: 'a4218000000T20V' ];
Id id='a4218000000T20V';
String[] tmpString = Member.Team_Members__c.split('\n');
Map<String, String> memberNames = new Map<String, String>();
for(String s: tmpString){
	//system.debug('s: ' +s);
	memberNames.put(s,s);  
}
system.debug(memberNames);


Set<String>cName = memberNames.keySet();
List<Contact>email = [SELECT Email FROM Contact where Name  LIKE : cName];
system.debug('email ' +email);
system.debug('cName: ' +cName);


Here the output of  system.debug('email ' +email); is the last email id that 'cName' is holding.
for example 'cName' has value as cName: {Member1, Member2, Member3}
However system.debug('email ' +email); gives output as email (Contact:{Email=Member3@AMC.com, Id=0037000001XaXXXXX3, RecordTypeId=012700000009oXXXXX, CurrencyIsoCode=USD})

I am expecting the output as email ids of all the members.
Please help me understand where I am going wrong.
Hello, 

I am trying to integrate Jira to Salesforce using service rocket plugin.
I am trying to run following code in Execute Anonymous
 
final static String JIRA_ENDPOINT = JIRA_Config__c.getInstance().JIRA_Endpoint__c;
HttpRequest req1 = new HttpRequest();
req1.setEndpoint(JIRA_ENDPOINT);
req1.setHeader('Content-Type', 'application/json');
req1.setMethod('GET');

Http http1 = new Http();
HttpResponse res1 = http1.send(req1);
system.debug(req1);
system.debug(res1);
system.debug(req1);
String username='nitin.palmure@pubmatic.com';
String password='Password@123';
String location;
String endpoint;
try{
while (res1.getStatusCode() == 302) {
    location = res1.getHeader('Location');
    endpoint = location +'&os_username=' +username +'os_password' +password+;
    //req1.setEndpoint(res1.getHeader('Location'));
    //req1.setMethod('GET');
    //req1.setHeader('Content-Type', 'application/json');
    res1 = new http().send(req1);
}
    }catch(Exception ex)
        {
            System.debug(ex);
        }
system.debug(res1.getStatusCode());
System.debug(res1.getHeader('Location'));
System.debug(res1.getHeader('Set-Cookie'));

Now the problem is that System.debug(res1.getHeader('Location')); is giving me our SSO login URL and system.debug(res1.getStatusCode());
How do I handle this situation so that I can get system.debug(res1.getStatusCode()); as 200 ?

Please help.

Regards
Nitin V Palmure
Hi Team, 

I would like to know if Salesforce considers syncing as update ?
Will it fire an after update or before update trigger once syncing is done between salesforce and other system ?

Regards,
Nitin V Palmure
Hello 

We have an integration between Jira and Salesforce. one of the field gets updated in Salesforce (say username__c) as soon as corresponding mapped field in Jira is getting updated (say username). Now is there a way in Salesforce to update a third field in salesforce as soon as username__c is synced with the new value updated in Jira ?

Regards,
Nitin V Palmure
I am trying to write a trigger which will send an email to fixed number of folks (Let's say 3). I was able to write a trigger for single user. However, I find it tricky to get it for three users. and would like to have some help.
Following is my code:
trigger triggerAlertonDeleteMarketplaceRule on Marketplace_Rule__c (before delete) {
	Messaging.reserveSingleEmailCapacity(trigger.size);
    List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
    Set<Id> accountIds = new Set<Id>();
    EmailTemplate Et = [SELECT Id from EmailTemplate where Name =: 'Marketplace Rule Deleted'];
    for(Marketplace_Rule__c acc : Trigger.old){
        if(acc.Related_Account__c != null){
            accountIds.add(acc.Related_Account__c);
        }
        }
     Map<Id, Account> accounts = new Map<Id, Account>([SELECT Id, Name FROM Account WHERE Id in :accountIds]);
        
   
    Contact tempContact = [SELECT Id FROM Contact WHERE email =: 'nitin.palmure@abc.com'];
  	
    for(Marketplace_Rule__c mpr : Trigger.old){
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        email.setTargetObjectId(tempContact.Id);
        email.setWhatId(mpr.id);
        email.setSaveAsActivity(false);
        email.setTemplateId(Et.Id);
        emails.add(email);
    }
    Messaging.sendEmail(emails);
  }

Please help me as there are three specific users lets take an example of three contacts with email Id as abc@123.com, def@123.com and ghi@123.com.
Thank you 
 
Hello, 

Previously I had written test classes for simple triggers, however I have never written a test class for extension with wrapper class and as complex logic as below. I need some help building a test class for this. 
Following is the extension that I have written and for which I am trying to write a test class.
/*
* Created Date: 04/06/2015
* Created By: Nitin V Palmure
* Description: MeetingAttendeeExt is an extenstion to Standard Controller Key Account Report.
* Visualforce page MeetingAttendee using this extension.
* This is adds field row as per the requirement of user and grabs parent call report ID in the url. This ID is used for pre populating 
* Key Account Report Name and redirection to parent call report after submit or cancel.
*/
public with sharing class MeetingAttendeeExt {
    public List<MeetingAttendeeWrapper> listMeetingAttendeeWrappers{get; set;}
    public static Integer toDelIdent{get; set;}
    public static Integer addCount{get; set;}
    public Integer nextIdent = 0;
    public static Key_Account_Report__c karName = new Key_Account_Report__c();  //variable to prepopulate the Key Account Report lookpup field of Meeting_Attendee__c object
    public String karId; // variable to store the ID of parent call report

    ApexPages.StandardController stdController;
    public MeetingAttendeeExt(ApexPages.StandardController stdController){
        this.stdController=stdController;
        karId = apexpages.currentpage().getParameters().get('Id');
        listMeetingAttendeeWrappers = new List<MeetingAttendeeWrapper>();
         karName= [SELECT Name FROM Key_Account_Report__c WHERE ID =: karId LIMIT 1];
        //for(Integer i = 0; i<5; i++){ //this line is commented so that only one row should be displayed on the page load. if uncommented that 5 rows will get displayed.
            listMeetingAttendeeWrappers.add(new MeetingAttendeeWrapper(nextIdent++,karId));
        //}//end for
       
    }// end constructor
    public void delWrapper(){
        Integer toDelPos = -1;
        for(Integer i = 0; i < listMeetingAttendeeWrappers.size(); i++){
            if(listMeetingAttendeeWrappers[i].ident == toDelIdent){
                toDelPos = i;
            }//End If
        }//End for
        if(-1 != toDelPos){
            listMeetingAttendeeWrappers.remove(toDelPos);
        }//End if
    }//End delWrapper menthod
    public void addRows(){
        for(Integer i = 0; i < addCount; i++){
            listMeetingAttendeeWrappers.add(new MeetingAttendeeWrapper(nextIdent++,karId));
        }//End For
    }//End addRows Method
    
    public PageReference save(){
        List<MeetingAttendee__c> meetAtts = new List<MeetingAttendee__c>();
        for(MeetingAttendeeWrapper wrap : listMeetingAttendeeWrappers){
            meetAtts.add(wrap.meetAtt);
        }//End For
        insert meetAtts;
        return new PageReference('/' + karId);
    }//End Save method
    public PageReference cancel(){
        return new PageReference('/' + karId);
    }//End cancel method
    public class MeetingAttendeeWrapper{
        public MeetingAttendee__c meetAtt{get; private set;}
        public Integer ident{get; private set;}
        public String ID {get; set;}
        
        public MeetingAttendeeWrapper(Integer inIdent, String Id){
            ident = inIdent;
            ID = Id;
            meetAtt = new MeetingAttendee__c(Key_Account_Report__c = Id);
            System.debug('Nitin::; line 51 karName: ' + Id);
        }//End constructor
    }//End wrapper class
}//End Class

Request you to please help me writing a test class for above, I have tried to start, however I am unable to figure out how can I write a test conditions where I will be add almost all the data on runtime.
 
@isTest
private class MeetingAttendeeExtTestClass {
    @isTest(SeeAllData=true)
    public static void testMeetingAttendeeExt(){
        ID karId = 'a0An00000007YGu';
        Key_Account_Report__c kar = [SELECT Name, Id FROM Key_Account_Report__c WHERE Id =: karId LIMIT 1];
        //List<MeetingAttendee__c> meetAtts = new List<MeetingAttendee__c>();
        //Reset all the governer limits.
        Test.startTest();
        //Inform Test Class to set current page as your page where extension is used.
        Test.setCurrentPage(Page.MeetingAttendee);
        
        //Instantiate object of "ApexPages.StandardController" by passing object of standard controller
        ApexPages.StandardController stdController = new ApexPages.StandardController(kar);
        
        //Create object of controller extension by passing object of standardController
        MeetingAttendeeExt ext = new MeetingAttendeeExt(stdController);
        ext.listMeetingAttendeeWrappers.add()
        //Finish Test
        Test.stopTest();
    }  
}

Request you to please help.

Regards, 
Nitin V Palmure
Hello,

I have multiple problems. But before that I want to share the code that I wrote.

Apex Class:
public with sharing class meetingAttendeeExtension {
    public List<MeetingAttendees__c> listMeetingAttendee {get; set;}
    MeetingAttendees__c meetingAttendee = new MeetingAttendees__c();
    public String KARId = apexpages.currentpage().getParameters().get('id');
    ApexPages.StandardController controller;
    public meetingAttendeeExtension(ApexPages.StandardController controller) {
        listMeetingAttendee = new List<MeetingAttendees__c>();
        listMeetingAttendee.add(meetingAttendee );
        controller = this.controller;
    }
    public void addMeetingAttendee(){
        MeetingAttendees__c meetAtt = new MeetingAttendees__c();
        listMeetingAttendee.add(meetAtt);
    }
    public PageReference saveMeetingAttendees() {
        for(Integer i=0; i<listMeetingAttendee.size(); i++)
        {
            insert listMeetingAttendee;
        }
        return new PageReference('/' + Schema.getGlobalDescribe().get('Key_Account_Report__c').getDescribe().getKeyPrefix() + '/o'); // this works but not what I am trying to acheive
        }
    public PageReference cancel(){
        return new PageReference('/' + controller.getId() );// returns null
    }
}

Visualforce Page: 
<apex:pageBlock >
             <apex:pageBlockSection title="Add Meeting Attendees" columns="1">
             <apex:pageBlockTable value="{!listMeetingAttendee}" var="meetAtt" id="customTable">
             <apex:column headerValue="Key Account Report Name">
                 <apex:inputField value="{!meetAtt.Call_Report__c}"/>
             </apex:column>
             <apex:column headerValue="Attendee Type">
                 <apex:inputField value="{!meetAtt.Attendee_Type__c}"/>
             </apex:column>
             <apex:column headerValue="Attendee Name">
                 <apex:inputField value="{!meetAtt.Attendee_Name__c}"/>
             </apex:column>
             </apex:pageBlockTable>
             </apex:pageBlockSection>
             <apex:pageBlockButtons >
                 <apex:commandButton value="Add Account Row" action="{!addMeetingAttendee}" rerender="customTable"/>
                 <apex:commandButton value="Save Meeting Attendees" action="{!saveMeetingAttendees}"/>
                 <apex:commandButton value="Cancel" action="{!cancel}" immediate="true"/>
             </apex:pageBlockButtons>
             
         </apex:pageBlock>
     </apex:form>
</apex:page>

Now there are following questions that I am trying to find but unable to implement.
Meeting_Attendees__c is child to Key_Account_Reports__c(Master Detail Relationship).
1. when I click "Add New Attendees", the name of Parent Key Account report does not poppulate by itself (how to do this)
2. controller.getId() gives me null, i am expecting to get parent ID here, is this right way ?

Solving above will help me acheive following.
1. Auto populate name of parent object so that user need not select it from the huge liste of Key Account Reports
2. create buttons which will navigate user to parent record, detail view page.

I found previous post related  to this https://developer.salesforce.com/forums/#!/feedtype=SINGLE_QUESTION_SEARCH_RESULT&id=906F000000090tcIAA

but this does not help.

Please suggest some way to acheive above.

Regards, 
Nitin V Palmure
I am trying to create a VF page where user can search for a record based on id field and edit it on the same page.
I have searched and found almost all the solutions which displays values in Tablular form.
I want to display the results in a Form fields itself and enable users to make changes and save.

Can anyone suggest on this ?

Thank you.
I am executing following code as execute anonymous
Competition__c Member = [SELECT Team_Members__c FROM Competition__c WHERE Id =: 'a4218000000T20V' ];
Id id='a4218000000T20V';
String[] tmpString = Member.Team_Members__c.split('\n');
Map<String, String> memberNames = new Map<String, String>();
for(String s: tmpString){
	//system.debug('s: ' +s);
	memberNames.put(s,s);  
}
system.debug(memberNames);


Set<String>cName = memberNames.keySet();
List<Contact>email = [SELECT Email FROM Contact where Name  LIKE : cName];
system.debug('email ' +email);
system.debug('cName: ' +cName);


Here the output of  system.debug('email ' +email); is the last email id that 'cName' is holding.
for example 'cName' has value as cName: {Member1, Member2, Member3}
However system.debug('email ' +email); gives output as email (Contact:{Email=Member3@AMC.com, Id=0037000001XaXXXXX3, RecordTypeId=012700000009oXXXXX, CurrencyIsoCode=USD})

I am expecting the output as email ids of all the members.
Please help me understand where I am going wrong.
Hello, 

I am trying to integrate Jira to Salesforce using service rocket plugin.
I am trying to run following code in Execute Anonymous
 
final static String JIRA_ENDPOINT = JIRA_Config__c.getInstance().JIRA_Endpoint__c;
HttpRequest req1 = new HttpRequest();
req1.setEndpoint(JIRA_ENDPOINT);
req1.setHeader('Content-Type', 'application/json');
req1.setMethod('GET');

Http http1 = new Http();
HttpResponse res1 = http1.send(req1);
system.debug(req1);
system.debug(res1);
system.debug(req1);
String username='nitin.palmure@pubmatic.com';
String password='Password@123';
String location;
String endpoint;
try{
while (res1.getStatusCode() == 302) {
    location = res1.getHeader('Location');
    endpoint = location +'&os_username=' +username +'os_password' +password+;
    //req1.setEndpoint(res1.getHeader('Location'));
    //req1.setMethod('GET');
    //req1.setHeader('Content-Type', 'application/json');
    res1 = new http().send(req1);
}
    }catch(Exception ex)
        {
            System.debug(ex);
        }
system.debug(res1.getStatusCode());
System.debug(res1.getHeader('Location'));
System.debug(res1.getHeader('Set-Cookie'));

Now the problem is that System.debug(res1.getHeader('Location')); is giving me our SSO login URL and system.debug(res1.getStatusCode());
How do I handle this situation so that I can get system.debug(res1.getStatusCode()); as 200 ?

Please help.

Regards
Nitin V Palmure
Hello,

I have multiple problems. But before that I want to share the code that I wrote.

Apex Class:
public with sharing class meetingAttendeeExtension {
    public List<MeetingAttendees__c> listMeetingAttendee {get; set;}
    MeetingAttendees__c meetingAttendee = new MeetingAttendees__c();
    public String KARId = apexpages.currentpage().getParameters().get('id');
    ApexPages.StandardController controller;
    public meetingAttendeeExtension(ApexPages.StandardController controller) {
        listMeetingAttendee = new List<MeetingAttendees__c>();
        listMeetingAttendee.add(meetingAttendee );
        controller = this.controller;
    }
    public void addMeetingAttendee(){
        MeetingAttendees__c meetAtt = new MeetingAttendees__c();
        listMeetingAttendee.add(meetAtt);
    }
    public PageReference saveMeetingAttendees() {
        for(Integer i=0; i<listMeetingAttendee.size(); i++)
        {
            insert listMeetingAttendee;
        }
        return new PageReference('/' + Schema.getGlobalDescribe().get('Key_Account_Report__c').getDescribe().getKeyPrefix() + '/o'); // this works but not what I am trying to acheive
        }
    public PageReference cancel(){
        return new PageReference('/' + controller.getId() );// returns null
    }
}

Visualforce Page: 
<apex:pageBlock >
             <apex:pageBlockSection title="Add Meeting Attendees" columns="1">
             <apex:pageBlockTable value="{!listMeetingAttendee}" var="meetAtt" id="customTable">
             <apex:column headerValue="Key Account Report Name">
                 <apex:inputField value="{!meetAtt.Call_Report__c}"/>
             </apex:column>
             <apex:column headerValue="Attendee Type">
                 <apex:inputField value="{!meetAtt.Attendee_Type__c}"/>
             </apex:column>
             <apex:column headerValue="Attendee Name">
                 <apex:inputField value="{!meetAtt.Attendee_Name__c}"/>
             </apex:column>
             </apex:pageBlockTable>
             </apex:pageBlockSection>
             <apex:pageBlockButtons >
                 <apex:commandButton value="Add Account Row" action="{!addMeetingAttendee}" rerender="customTable"/>
                 <apex:commandButton value="Save Meeting Attendees" action="{!saveMeetingAttendees}"/>
                 <apex:commandButton value="Cancel" action="{!cancel}" immediate="true"/>
             </apex:pageBlockButtons>
             
         </apex:pageBlock>
     </apex:form>
</apex:page>

Now there are following questions that I am trying to find but unable to implement.
Meeting_Attendees__c is child to Key_Account_Reports__c(Master Detail Relationship).
1. when I click "Add New Attendees", the name of Parent Key Account report does not poppulate by itself (how to do this)
2. controller.getId() gives me null, i am expecting to get parent ID here, is this right way ?

Solving above will help me acheive following.
1. Auto populate name of parent object so that user need not select it from the huge liste of Key Account Reports
2. create buttons which will navigate user to parent record, detail view page.

I found previous post related  to this https://developer.salesforce.com/forums/#!/feedtype=SINGLE_QUESTION_SEARCH_RESULT&id=906F000000090tcIAA

but this does not help.

Please suggest some way to acheive above.

Regards, 
Nitin V Palmure