• shrey.tyagi88@tcs.com
  • NEWBIE
  • 115 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 124
    Questions
  • 138
    Replies

I have this follwoing scenario . Can someone please help?

50% of employees in my org have active salesforce licenses. They log into the org via SSO through Active Directory . So in this case :

My Salesforce org is an SP (with SSO settings enabled)

&&

AD is my Idp

Also, I have another Web Based app called "Booking Portal". I want all my Salesforce users to seamlessly log into my Booking Portal app.

 

How can I do this?

 

Can I add Booking portal as my canvas app and enable SAML ? In this case Salesforce will be my IdP . Is this doable?

What’s the best way to store Payment Information for your Customer Community Users?
 
Customer community user would like to store different Credit Card info. for future payments. Just the way we as users store different credit cards @ Amazon.com. What’s the best way to incorporate this requirement?
 
I am thinking of having a custom Object related to Account that can carry different card information. Any better solution?
 
There is something called “Payment Methods” in Salesforce. As per my research this comes under Salesforce Billing, which would need a CPQ License. Is my understanding correct here?
 
https://help.salesforce.com/articleView?id=blng_payment_methods.htm&type=5
 
Can you Partnet community users resolve Salesforce cases for your company?

Scenario: You sold a product through a partner community user . Customer raises a case against that product, can you assign that case to your partner user and expect partner to resolve it?

Salesforce documentation is confusing and contradisctory in this case. It says Cases can be assigned to Partner User here:

https://help.salesforce.com/articleView?id=networks_partners_cases_assign.htm&type=5

But in the link given below it also says that external users cannot update Case status, whats the point of assigning the case to prtner users if it cannot be updated by them?

https://help.salesforce.com/articleView?id=networks_enable_cases_for_external_users.htm&type=0

I dont have a partner licnese , else would have tried this myself . Can anyone help me out here?
 
Hi All,

I have a requirement here , can anyone help me ??

Custom Object : Name - "Test Object"
Sharing Setting : Private
Manual Sharing : Enabled (By displaying custom button on the Page Layout)

Users are allowed to share the records with "Role A and its subordinates" as and when required , but should be prohibited to share the records with "Role B and its subordinates". 

Can we add some sort of capability that prohibits user from giving access to anyone apart from "Role A and its subordinates" ?
Hi Everyone,
     I have a lightning component (a button on record detail page) that opens a new window when clicked. I want the new window to open in the modal window instead of a new tab. Can anyone help me with the code given below?

Lightning Component:

<aura:component controller="Utils" implements="force:lightningQuickAction,force:hasRecordId">
    <iframe width="720" height="480" scrolling="yes" src="https://www.google.com/"></iframe>
    <aura:attribute name="recordId" type="Id" />
    <aura:handler name="init" value="{!this}" action="{!c.openActionWindow}"/> 
</aura:component>

Lightning Controller:

({
    openActionWindow : function(component, event, helper) {
        var oppId = component.get("v.recordId");
        var action = component.get("c.ActiveSessionId");
        var returnURL = $A.get("$Label.LightningDocUploadRetURL");
       action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
              var tempVars = response.getReturnValue();
              var urlEvent = $A.get("e.force:navigateToURL");
                 urlEvent.setParams({
                 "url": 'http://webservicesstage.rti.org/OnBaseUpload/?Type=Opportunity&sessionId='+tempVars+'&recordId='+oppId
                });
               urlEvent.fire();
            }
        });
        
    $A.enqueueAction(action);
        

    } ,
    

    
})
Now instead of google.com I want the URL to go in that iframe. Can anyone help??
Hi,
  I have a requirement where I need a lightning Modal/Pop up box to load a URL upon click of a button. Can someone please help me with the sample code?  There are plenty of examples on how to open a modal box , but none indicates if we can load a URL in it or not.
Hi All ,
    I need to open a pop-up window from a record detail page . I got my hands on the following snippet of code that works just fine.

<aura:component implements="force:lightningQuickAction" >
    <ui:button label="Open in New window" press="{!c.openActionWindow}"/>
</aura:component>

Controller-

({
    openActionWindow : function(component, event, helper) {
         window.open("https://www.w3schools.com");
    }
})

Now in this code when you click on a button (on record detail page)a pop up comes in front and asks you to click a button (Label-Open in new window). I want to disable this behavior, I want that when I click the button on record detail page, a pop up should have the url (w3 schools) loaded into it.And I also want to pass a record parameter in the URL , say Opportunity.Id.
Is User De-provisioning also supported in Just In Time (JIT) User Provisioning Mechanism????


If I want to make a particular user inactive using JIT . Can this be done?
Hi Everyone,
     I have a pretty straightforward requirement here. I have an <apex:input text > box on my page  and a <apex:commandbutton>. The command button point to a website e.g. google.com . I want when user enters the value in input text and clicks on the button , the button should open a new page with google.com/inputtextvalue. Can anyone please help me with this?


<apex:inputtext value="{!searchText}" id="DocumentText" rendered="true" />
<apex:commandLink > id="linkt" action="{!processLinkClick}">Search OnBase</apex:commandLink>


apex Code:
 public string searchText{get;set;}
 public PageReference processLinkClick() {
    return new PageReference('www.google.com/'+searchText);
 }
Hi All,
    I am facing a known issue. As per salesforce documentation "Process Flows are deactivated upon deployment". Now I have a scenario where a checkbox toggles from False to True in parent record , process flow fires and invokes an apex class, that class creates a child record related to that parent. Now at the time of deployment my process flow is deactivated , so when I query the child records in my test class I get the error "List has no rows for assignment". 
Now to compensate for the inactive flow how can I imitate the exact firing logic in my apex test class?

Test Class sample is given below:

@isTest
public class Test_PrasApexCode {
    
    static testMethod void testDoGet1() {
        
        
        
        Costpoint_Project__c testCostpointProject = new Costpoint_Project__c();
        testCostpointProject.Business_Unit__c='SSES';
        testCostpointProject.Unit__c='EHS';
        testCostpointProject.Division__c='Environment';
        testCostpointProject.Review_Required__c=False;
        testCostpointProject.Project_Manager__c=u1[0].Id;
        insert testCostpointProject;
        
        
       
        
        
        Awarded_Project__c ap= new Awarded_Project__c();
        ap.Opportunity__c=testOpp.Id;
        ap.Project__c=testCostpointProject.Id;
        insert ap;
        

       ///////////////////////Process flow fires here//////////////////////////////////
        testCostpointProject.Review_Required__c=True;
        update testCostpointProject;

///////////////////////////////////////////////////////////////////////////////////////////////////
        

        
        
        //Fetch related Project Risk Review form.
       //This is where the error is thrown
        Project_Risk_Review__c ProRiskRev=[Select id,DVP__c,Project_Manager__c,Chair_Reviewer__c,Delegate__c 
                                           from Project_Risk_Review__c where Costpoint_Project__c=:testCostpointProject.Id Limit 1];

        
        ProRiskRev.Chair_Reviewer__c=u1[0].Id;
        ProRiskRev.DVP__c=u1[1].Id;
        Update ProRiskRev;


        

    
    }
    

}
HI All,
    I have a scenario which I want to discuss and confirm whether the anyone else has experienced the same issue or not. 

I am deploying a change set of 400 components. The flows are in that change set alnong with the test classes. Now, I use flows to create records of custom object "Project Review" and then I have written test classes that fetch those newly created "Project Review" records . When I run my tests in sandbox (with active flow) all of the test cases pass and I get good coverage. But when I validate the same change set for deployment , exactly at point where "Project Review "records are queried in test class - A list has no records error gets thrown out to me. 

Salesforce Says : 'An active flow in a change set is deployed to its destination as inactive. Activate the flow manually after deployment.' 

I googled this and found that even active flows upon deployment are deactivated initially. Is this the reason why I may be facing this issue ? Becuase my active flows of change sets are deactivated initially upon deployment , I dont get any records created for my test class and exception error gets in .



Just want to confirm my guess here. Thanks for your help ...


Regards
Shrey Tyagi
Hi All ,
     I have this VF page that renders the page as PDF file upon click of a button . This works well in salesforce , however it does not work and goes to salesforce login screen when the button is clicked on Force.com site . Please help. I have explicitly given access of this page to the site as well. 

Button : Generate PDF (On Object Detail Page- This page is accessible from force.com site as well , button is also visible to site users.)

Visualfoce Page tied to the button mentioned above is given below:


<apex:page standardController="Project_Form__c" showHeader="true" tabStyle="Project_Form__c" renderas="pdf" >
   <apex:detail relatedList="false" title="true"/>
</apex:page>
Hi All-
     I need your help in writing a test class for the following batch apex class. This batch creates new child records on being processed. I saw multiple posts where batches update the exisiting record and understood how to writes a test class for the same. But since my batch is creating completely new records I am having difficulty in writing its test class. I have written something but that does not cover the entire execute methos , it covers everything else. Please help me.

Batch Class: 

global class CreateNewSummaryFormRecords implements Database.Batchable<Sobject>, Database.Stateful {

    global Database.QueryLocator start(Database.BatchableContext bc) {
        //first, you gather all the records you want to create a new record with
        String query = 'Select Id,Risk_Assessment_Active__c,Project_Manager__c,Chair_Reviewer__c from Project_Risk_Review__c where Risk_Assessment_Active__c = true and Review_Meeting_Date_Tentative__c = False and Number_Of_Days_For_Next_Review__c=2';
        //below checks to see if the batch is being called from a test class. If the record count
        //returned by the query above is over 200, the test will fail
        if(Test.isRunningTest())
            query += ' limit 200';
        return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext bc, List<Project_Risk_Review__c> originalrecords){
        //now we want to loop through the records from the query above and create the new records
        //and store them in a list
        List<Project_Form__c> newrecords = new List<Project_Form__c>();
        
        for(Project_Risk_Review__c yo1:originalrecords){ // this is the loop
            Project_Form__c yo2 = new Project_Form__c(); //this sets up a new record to be created
            yo2.Project_Risk_Assessment__c= yo1.Id;
            yo2.RecordTypeId=Label.PRAS_Project_Summary_Form_Record_Type;
            yo2.Project_Manager__c=yo1.Project_Manager__c;
            yo2.Chair_Reviewer__c=yo1.Chair_Reviewer__c;
            //add any other fields on the new record that you want to set
            newrecords.add(yo2); 
            //add to list to insert into SFDC later
        }

        //this checks to see if there are any records to insert. If there are, then it will 
        //create them
        if(!newrecords.isEmpty())
            database.insert(newrecords,false); 
        //newrecords is the list of records you put in during the for loop. The "false" is saying,
        //if one records fails to insert, still insert the rest (All or Nothing)
    }
    
    global void finish(Database.BatchableContext bc) {}
}

Sample Test Class:


@isTest
public class CreateNewSummaryFormRecordsTest
{
 
  static testMethod void testMethod1(){
        Account testAccount = TestUtil.generateTestAccount();
        insert testAccount;

        Opportunity testOpp = new Opportunity();
        testOpp.Name = 'Opportunity For Unit Test';
        testOpp.AccountId = testAccount.Id;
        testOpp.StageName = 'Qualification';
        testOpp.CloseDate = Date.Today().AddDays(365);
        testOpp.Org__c= '1010101';
        testOpp.Project_Director__c = UserInfo.getUserId();
        testOpp.RAQ_Human_Subjects__c='Yes';
        testOpp.Amount=1000000;
        testOpp.Estimated_Subcontractor_Amount__c=1000000;
        insert testOpp;
        
       
        List<User> u1= [SELECT Id,IsActive FROM User WHERE isActive=True and ProfileId=:Label.PRAS_RTI_BusinessDevelopment_Profile_Id Limit 4];
        List<User> u2= [SELECT Id,IsActive FROM User WHERE isActive=False and ProfileId=:Label.PRAS_RTI_BusinessDevelopment_Profile_Id Limit 1];
        
        Costpoint_Project__c testCostpointProject = new Costpoint_Project__c();
        testCostpointProject.Name = '0281300.003';
        testCostpointProject.Project_Name__c = '0281300.003';
        testCostpointProject.Project_Number__c = '0281300.003';
        testCostpointProject.Owning_Reorg_Level_6__c='1.2.1.30.03.03';
        testCostpointProject.Contract_Type__c='GRANT';
        testCostpointProject.Contract_Value__c=100000000;
        testCostpointProject.Business_Unit__c='SSES';
        testCostpointProject.Unit__c='EHS';
        testCostpointProject.Division__c='Environment';
        testCostpointProject.Review_Required__c=False;
        testCostpointProject.Project_Manager__c=u1[0].Id;
        insert testCostpointProject;
        
       
        //Fetch related Project Risk Review form.
        Project_Risk_Review__c ProRiskRev=[Select id,DVP__c,Project_Manager__c,Chair_Reviewer__c,Delegate__c 
                                           from Project_Risk_Review__c where Costpoint_Project__c=:testCostpointProject.Id Limit 1];
                                            ProRiskRev.Chair_Reviewer__c=u1[0].Id;
        ProRiskRev.DVP__c=u1[1].Id;
        ProRiskRev.Project_Manager__c=u1[2].Id;
        ProRiskRev.Delegate__c=u1[3].Id;
        Update ProRiskRev;
        ProRiskRev.Chair_Reviewer__c=u1[3].Id;
        ProRiskRev.DVP__c=u1[2].Id;
        ProRiskRev.Project_Manager__c=u1[1].Id;
        ProRiskRev.Delegate__c=u1[0].Id;
        Update ProRiskRev;
        
        Project_Form__c ProForm=new Project_Form__c();
        ProForm.Project_Risk_Assessment__c=ProRiskRev.Id;
        ProForm.RecordTypeId=Label.PRAS_Project_Summary_Form_Record_Type;
        ProForm.Project_Manager__c=ProRiskRev.Project_Manager__c;
        ProForm.Chair_Reviewer__c=ProRiskRev.Chair_Reviewer__c;
        insert ProForm;
        
        
        Test.startTest();
        CreateNewSummaryFormRecords obj = new CreateNewSummaryFormRecords();
        DataBase.executeBatch(obj);
        Test.stopTest();

 
         
 }

}
 
Hi Evryone ,
   I have this pretty simple code given below. Now everything works well here. What i want to do is, rather than the record being displayed as a 1 row with 3 columns. I want it to be displayed as 1 column 3 rows. Can anyone please help me with this?

Current Display Format : Name, Narrative Technical, Narrative Staffing
Desired Display Format : Name 1
                                             Narrative Technical 1
                                             Narrative Staffing 1
                                         Name 2
                                             Narrative Technical 2
                                             Narrative Staffing 2

<apex:page standardController="Project_Form__c" recordSetVar="ProjectForms">
    <apex:sectionHeader title="Form History"/>
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages />

            <apex:pageBlockSection title="Selected Project Review Forms" columns="1">
                 <apex:pageBlockTable value="{!selected}" var="form" columns="3">
                    <apex:column value="{!form.name}"/>
                    <apex:column value="{!form.Narrative_Technical__c}"/><br></br>
                    <apex:column value="{!form.Narrative_Staffing__c}"/><br></br>
                  </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Hi Everyone,
        I have a question on how to cover exceptions of Database.Save method. The method I want to cover is given below:

Apex Code : 
     Database.SaveResult[] lsr = Database.insert(GateReviewShrs,false); 
     // Create counter
     Integer i=0;
     // Process the save results
        for(Database.SaveResult sr : lsr){
            if(!sr.isSuccess()){
                // Get the first save result error
                Database.Error err = sr.getErrors()[0];
                if(!(err.getStatusCode() == StatusCode.FIELD_FILTER_VALIDATION_EXCEPTION  
                                               &&  err.getMessage().contains('AccessLevel'))){

                    trigger.newMap.get(GateReviewShrs[i].ParentId).
                      addError(
                       'Unable to grant sharing access due to following exception: '
                       + err.getMessage());
                }
            }
            i++;
        }
I am trying to cover this exception by making a wrong entry in my test class (one of inactive user). Code given below: 


@isTest
public class Test_PrasApexCode {
    
    static testMethod void testDoGet1() {



        
        Costpoint_Project__c testCostpointProject = new Costpoint_Project__c();
        testCostpointProject.Name = '0281300.003';

        insert testCostpointProject;

        //Fetch related Project Risk Review form.
        Project_Risk_Review__c ProRiskRev=[Select id,DVP__c,Project_Manager__c,Chair_Reviewer__c,Delegate__c 
                                           from Project_Risk_Review__c where Costpoint_Project__c=:testCostpointProject.Id];

        List<User> u2= [SELECT Id FROM User WHERE isActive=False and ProfileId=:Label.PRAS_RTI_BusinessDevelopment_Profile_Id Limit 1];

  
         ProRiskRev.Delegate__c=u2[0].Id;
         Update ProRiskRev;
      
But when I try to do this my coverage increases but test method fails . It has to fail because the user is inactive. Is there any way to pass the test method and increase the coverage?
 

Hi Everyone,
       I am looking for a solution for the following problem.

 

There is an object called "Test Object". It has 13 fields in total. Let's annotate them F1-F10 (ALL CHECKBOXES)  and U1-U3 (All user lookups).

OWD: Public Read/Write
All Profiles (except Admin): Read Only on Record and only F1-F5 are visible, F6-F10 are hidden.
Super User: Read/Write (using permission set on all fields F1-F10 AND U1-U3)

Now as per the requirement, whenever the super user edits a record and adds U1,U2,U3 to it 2 things should happen:

1. U1,U2,U3 should get Read/Write on Record (done this by Apex sharing).
2. U1,U2,U3 should get access to all fields : Specially F6-F10 that are hidden by default due to profiles.

Is there a way to show fields (that are hidden at profile level) to U1,U2 and U3 only  on a record by record basis.

Please let me know. Thanks.

Hi Everyone,
       I am looking for a solution for the following problem.

 

There is an object called "Test Object". It has 13 fields in total. Let's annotate them F1-F10 (ALL CHECKBOXES)  and U1-U3 (All user lookups).

OWD: Public Read/Write
All Profiles (except Admin): Read Only on Record and only F1-F5 are visible, F6-F10 are hidden.
Super User: Read/Write (using permission set on all fields F1-F10 AND U1-U3)

Now as per the requirement, whenever the super user edits a record and adds U1,U2,U3 to it 2 things should happen:

1. U1,U2,U3 should get Read/Write on Record (done this by Apex sharing).
2. U1,U2,U3 should get access to all fields : Specially F6-F10 that are hidden by default due to profiles.

Is there a way to show fields (that are hidden at profile level) to U1,U2 and U3 only  on a record by record basis.

Please let me know. Thanks.


 

Hi Everyone ,
         I have a requirement with me and I need some help. Please find the details of the requirement given below.

1. I have a vf search page that searched on opportunity records and returns results. On opportunity name column of result section I want user to click , upon user click in tyhe bottom half of the search page , another vf page (inline) should open up . I have the code given below. Just need help with passing the reocrd id parameter from command link to detail page and it's controller.


 Search Page code:


    <apex:pageBlock mode="edit" id="results">

        <apex:pageBlockTable value="{!Opportunities}" var="opp">

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Opportunity Name" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Name" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                // This section represents column of serach results.
                <apex:commandlink value="{!opp.Name}" rerender="RecordDetailSection" action="{!ClearOrder}">
                    <apex:param name="abc" value="{!opp.id}"/>
                </apex:commandlink>
                

        </apex:pageBlockTable>    
 </apex:pageBlock>

// This section is inline details page of click opportunity
      
  <apex:pageBlock id="RecordDetailSection" rendered="{!RenderDetail}">
     <apex:include pageName="SiteDetailPage"/>
  </apex:pageBlock>

</apex:page>



Site detail Page controller:


public class CurrentRecordIdDemoController{
public String currentRecordId {get;set;}
public String parameterValue {get;set;}
public Opportunity Opp{get;set;}
public Integer DocSize{get;set;}




    public CurrentRecordIdDemoController() {
        //currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
        Id currentRecordId = System.currentPageReference().getParameters().get('abc');
        Opp = [select  Awarded_Project__c,(Select Doc_Name__c,Link__c,Type__c,CreatedDate from Documents__r Order By CreatedDate desc) from Opportunity where id =: currentRecordId ];
        parameterValue = ApexPages.CurrentPage().getparameters().get('nameParam');
        DocSize=Opp.Documents__r.size();
        
    }

}
Hi Everyone,
            I have a field called department . Possible values of department are given below . I want to make a formula taht looks for "-" betwwen the words and shortens the value from left hand side for e.g:

Original value : SSES-SPHERE-BHCJ-JSR-PSIS
Final Value: SSES-SPHERE

Original Value: ADM-CFO-FIN-CTLR
Final Value: ADM-CFO


Can anyone help me here please???

Regards
Shrey Tyagi

 
Hi Everyone,
    I have a profile called "Business Development". Users (who are also owners of the case) of this profile have only Read access on the 2 existing record types (lets call them A and B) of Case Object. I want users (who are also owners of the case) of this profile to have Edit access on a new case record type (lets call it C)  . So Here is the situation 

Case OWD: Private
Case Acess : A and B Record Type: Read Only- Already Exisitng Record Types
                     C record Type : Read Write : New Record Type.

Now to grant Access only to C record Type I wrote an apex class., it is given below:

    public static void determineFDMCaseOwnersAccess(List<Case> newFDMCasesBD) {
        List<Id> OwnerIdList=new List<Id>();
        Map<Id,Id> UserMap=new Map<Id,Id>();
        List<CaseShare> CaseShareRecordList  = new List<CaseShare>();
        CaseShare CaseShareRecord=new CaseShare();
        for(Case css:newFDMCasesBD){
            OwnerIdList.add(css.OwnerId);
        }
        List <User> UserList=[Select Id,ProfileId from User where Id IN:OwnerIdList AND ProfileId=:'00eG0000000FnxC'];
        for(User uss:UserList){
            UserMap.put(uss.Id,uss.ProfileId);
        }
        for(Case css:newFDMCasesBD){
            if(UserMap.get(css.OwnerId)!=null && css.RecordTypeId==Label.Case_Record_Type_FDM){
              CaseShareRecord=new CaseShare();
              CaseShareRecord.CaseId=css.Id;
              CaseShareRecord.UserOrGroupId=css.OwnerId;
              CaseShareRecord.CaseAccessLevel='Edit';
              CaseShareRecord.RowCause ='Owner';
              CaseShareRecordList.add(CaseShareRecord);
            }
        }
        if(CaseShareRecordList.size()>0){
            Database.SaveResult[] lsr = Database.insert(CaseShareRecordList,false);
        }
    
    } 

This code works well and inserts CaseShare records , but on querying them it turns out that their access level is All, instead of Edit as given in the code. Also Users are unable to edit the case even post Case Share record creation. 

Is it because the sharing is being done by the case owner itself? Why cant user edit the records if he/she has CaseShare with All as access level?


Please help me with this!!!


Regards
Shrey Tyagi

 

Hi Everyone,
       I am looking for a solution for the following problem.

 

There is an object called "Test Object". It has 13 fields in total. Let's annotate them F1-F10 (ALL CHECKBOXES)  and U1-U3 (All user lookups).

OWD: Public Read/Write
All Profiles (except Admin): Read Only on Record and only F1-F5 are visible, F6-F10 are hidden.
Super User: Read/Write (using permission set on all fields F1-F10 AND U1-U3)

Now as per the requirement, whenever the super user edits a record and adds U1,U2,U3 to it 2 things should happen:

1. U1,U2,U3 should get Read/Write on Record (done this by Apex sharing).
2. U1,U2,U3 should get access to all fields : Specially F6-F10 that are hidden by default due to profiles.

Is there a way to show fields (that are hidden at profile level) to U1,U2 and U3 only  on a record by record basis.

Please let me know. Thanks.


 

Hi Everyone,
     I am taking baby steps towards REST apex  functionalliy and have developed some code (which fortunately woorks). Now I need your help in enhancing its operations. Please find the summary given below:

Using a json (given below) I managed to create an account record in salesforce:

{
   "acct":
   {
     "Name":"Jag"
   }

}

Apex Code:
@RestResource(urlMapping='/v1/accounts/*')
global with sharing class MyRestResource {
@HttpPost
    global static AccountWrapper doGet(Account acct) {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        AccountWrapper response= new Accountwrapper();
        try{
         insert acct;
         response.message='Mogamgo Khush Hua :)';
        }
        catch(Exception exc){
         response.message='Mogamgo Dukhi Hua :('; 
        }
       return response;
    }
      global class AccountWrapper {
      public Account acct;
      public String status;
      public String message;
      public AccountWrapper(){}

    }

}
Now I want to modify my apex code so that it can take a json with 1 account and 3 contacts in it and insert them in salesforce. Sample json is given below , can anyone please guide me with the modifications that are to be done in my apex class?


{
  "rqst":{
        "acct":{
         "Name":"Jag"
        }
        "conlist":{
         [
           {"FirstName":"Test","LastName":"Test"},
           {"FirstName":"Test1","LastName":"Test1"}
         ]
        }
  }

}
 

Hi,

   I need to build a visualforce page that does the following:

1. It has a controlling  picklist that displays all the custom and standard objects of the org.

2. It has a dependent multi select picklist of all the fields of object selected in controlling picklist mentioned above.

 

    Please help me with the code.I 've found few examples , but they use sObjects (list) . I don't want to go through that approach. Is there a better way?

 

Hi All ,
    I need to open a pop-up window from a record detail page . I got my hands on the following snippet of code that works just fine.

<aura:component implements="force:lightningQuickAction" >
    <ui:button label="Open in New window" press="{!c.openActionWindow}"/>
</aura:component>

Controller-

({
    openActionWindow : function(component, event, helper) {
         window.open("https://www.w3schools.com");
    }
})

Now in this code when you click on a button (on record detail page)a pop up comes in front and asks you to click a button (Label-Open in new window). I want to disable this behavior, I want that when I click the button on record detail page, a pop up should have the url (w3 schools) loaded into it.And I also want to pass a record parameter in the URL , say Opportunity.Id.
HI All,
    I have a scenario which I want to discuss and confirm whether the anyone else has experienced the same issue or not. 

I am deploying a change set of 400 components. The flows are in that change set alnong with the test classes. Now, I use flows to create records of custom object "Project Review" and then I have written test classes that fetch those newly created "Project Review" records . When I run my tests in sandbox (with active flow) all of the test cases pass and I get good coverage. But when I validate the same change set for deployment , exactly at point where "Project Review "records are queried in test class - A list has no records error gets thrown out to me. 

Salesforce Says : 'An active flow in a change set is deployed to its destination as inactive. Activate the flow manually after deployment.' 

I googled this and found that even active flows upon deployment are deactivated initially. Is this the reason why I may be facing this issue ? Becuase my active flows of change sets are deactivated initially upon deployment , I dont get any records created for my test class and exception error gets in .



Just want to confirm my guess here. Thanks for your help ...


Regards
Shrey Tyagi
Hi All ,
     I have this VF page that renders the page as PDF file upon click of a button . This works well in salesforce , however it does not work and goes to salesforce login screen when the button is clicked on Force.com site . Please help. I have explicitly given access of this page to the site as well. 

Button : Generate PDF (On Object Detail Page- This page is accessible from force.com site as well , button is also visible to site users.)

Visualfoce Page tied to the button mentioned above is given below:


<apex:page standardController="Project_Form__c" showHeader="true" tabStyle="Project_Form__c" renderas="pdf" >
   <apex:detail relatedList="false" title="true"/>
</apex:page>
Hi Everyone,
        I have a question on how to cover exceptions of Database.Save method. The method I want to cover is given below:

Apex Code : 
     Database.SaveResult[] lsr = Database.insert(GateReviewShrs,false); 
     // Create counter
     Integer i=0;
     // Process the save results
        for(Database.SaveResult sr : lsr){
            if(!sr.isSuccess()){
                // Get the first save result error
                Database.Error err = sr.getErrors()[0];
                if(!(err.getStatusCode() == StatusCode.FIELD_FILTER_VALIDATION_EXCEPTION  
                                               &&  err.getMessage().contains('AccessLevel'))){

                    trigger.newMap.get(GateReviewShrs[i].ParentId).
                      addError(
                       'Unable to grant sharing access due to following exception: '
                       + err.getMessage());
                }
            }
            i++;
        }
I am trying to cover this exception by making a wrong entry in my test class (one of inactive user). Code given below: 


@isTest
public class Test_PrasApexCode {
    
    static testMethod void testDoGet1() {



        
        Costpoint_Project__c testCostpointProject = new Costpoint_Project__c();
        testCostpointProject.Name = '0281300.003';

        insert testCostpointProject;

        //Fetch related Project Risk Review form.
        Project_Risk_Review__c ProRiskRev=[Select id,DVP__c,Project_Manager__c,Chair_Reviewer__c,Delegate__c 
                                           from Project_Risk_Review__c where Costpoint_Project__c=:testCostpointProject.Id];

        List<User> u2= [SELECT Id FROM User WHERE isActive=False and ProfileId=:Label.PRAS_RTI_BusinessDevelopment_Profile_Id Limit 1];

  
         ProRiskRev.Delegate__c=u2[0].Id;
         Update ProRiskRev;
      
But when I try to do this my coverage increases but test method fails . It has to fail because the user is inactive. Is there any way to pass the test method and increase the coverage?
 
Hi Everyone,
              Just a quick question for you all. I have opportunity and Account bothe private . If I grant someone acess to opportunity record , via manaul share or opportunity team , what will be the new access of that person on the related account record? Does it work the same way for cases/contact as well?

Regards
Shrey Tyagi
Hi Everyone,
             I have a requirement with me . I need to do a validation when opportunity team member is added to the opportunity. The requirement is that , user must not be able to add a new opportunity team member on an opportunity which has its close date in the past . I have written a before insert trigger on Oppotunity team member . Need your help in getting SOQL out of for Loop. I know it can be done via map , just need some pointers to get started on this.

Sample code:

for(OpportunityTeamMember member : Trigger.new)
      {
        Opportunity opp= Select CloseDate from Opportunity where Id = member.OpportunityId ;
        if (opp.closedate<system.today()){
         member.adderror('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
        }
      }
Hi Everyone,
           I am running into a small issue here.  Need help just with 1 line of syntax. So I have an object called Project Form , which is looking up to its parent called costpoint project . There is a user field on costpoint record (project team member 1) . I want an apex sharing record (on project form) to get created whenever a project form is added to a particular costpoint project .  All is working well, just the syntax to pass on the Id of the user from parent record seems to go awry . Please help me with the code given below, I have underscored the lines .


 for(Project_Form__c ProjectForm : trigger.new){
            // Instantiate the sharing objects
            teamMemberShr = new Project_Form__Share();
            
            
            // Set the ID of record being shared
            teamMemberShr.ParentId = ProjectForm.Id;
            
            
            // Set the ID of user or group being granted access
            //teamMemberShr.UserOrGroupId = ProjectForm.Costpoint_Project__r.Project_Team_Member_1__c;
            system.debug('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: ' + ProjectForm.Costpoint_Project__r.Project_Team_Member_1__c);
         
            teamMemberShr.UserOrGroupId = '005G0000001to4iIAA';
            
            // Set the access level
            teamMemberShr.AccessLevel = 'read';
            
            
            // Set the Apex sharing reason for hiring manager and recruiter
            teamMemberShr.RowCause = Schema.Project_Form__Share.RowCause.Project_Team_Member__c;
            
            
            // Add objects to list for insert
            ProjectFormShrs.add(teamMemberShr);
            
        }
Hi Everyone,
         I have written a @HTTP Post method which works fine. I need a sample code to write it's test class . Can anyone  please help me with this? My test method is giving an error saying that method doPost() does not exist (second last line).

Apex Code:

@RestResource(urlMapping='/v1/cans/*')
global with sharing class MyRestResource {
  @HttpPost
    global static DocWrapper doPost(String Description, String ParentId, String FilePathname, String Name, String Type) {
        DocWrapper response=new DocWrapper();
        Document__c doc= new Document__c();
        doc.Doc_Name__c=Name;
        doc.Type__c=Type;
        doc.CAN__c=ParentId;
        doc.Link__c=FilePathname;
        doc.Description__c=Description;
        insert doc;
        response.message='Doc Inserted';
        return response;
        
     }
       global class DocWrapper {          
          public String message;
     }
}

Test Method:


static testMethod void testDoPost(){
        
        RestRequest req = new RestRequest(); 
        RestResponse res = new RestResponse();
        
        RecordType RecType = [Select Id From RecordType  Where SobjectType = 'CAN__c' and Name = 'CAN Fed'];    
        CAN__c cf = new CAN__c (Name='Test CAN 1',RecordTypeId=RecType.Id);
        insert cf;
        String CanId=cf.id;
        
        req.requestURI = '/services/apexrest/v1/cans/';  
        req.addParameter('Description', '0000000');
        req.addParameter('ParentId',CanId);
        req.addParameter('FilePathname', 'www.google.com');
        req.addParameter('Name', '1wer2547');
        req.addParameter('Type', '1wer2547');

        req.httpMethod = 'POST';
        RestContext.request = req;
        RestContext.response = res;
        
        Test.startTest();
        MyRestResource.DocWrapper results = MyRestResource.doPost();
        Test.stopTest();
        

    }
Hi Everyone,
              I have written a trigger that posts a feed on Accdount record whenever a child gets inserted. This trigger works fine , but I am struggling to add multi word topics to it. Please finde the code given below:

trigger CreateChatterFeedOnAccount on Chatter_Feed__c (after insert) {

List<FeedItem> lstFeeds = new List<FeedItem>();
String BodyOfFeed;
 if(Trigger.isInsert && Trigger.isAfter){
        for(Chatter_Feed__c cf : trigger.new) {
         FeedItem fi = new FeedItem();
         fi.ParentId = cf.Account__c;
         fi.Title= cf.Title__c;
         BodyOfFeed =  cf.Description__c;
         if(cf.link__c!= null){
            fi.Type = 'LinkPost';
            fi.LinkUrl = cf.link__c; 
         }
          if(cf.Topic_1__c!= null){BodyOfFeed=BodyOfFeed+' #'+cf.Topic_1__c;}
          if(cf.Topic_2__c!= null){BodyOfFeed=BodyOfFeed+' #'+cf.Topic_2__c;}
          if(cf.Topic_3__c!= null){BodyOfFeed=BodyOfFeed+' #'+cf.Topic_3__c;}
          if(cf.Topic_4__c!= null){BodyOfFeed=BodyOfFeed+' #'+cf.Topic_4__c;}
          if(cf.Topic_5__c!= null){BodyOfFeed=BodyOfFeed+' #'+cf.Topic_5__c;}

          fi.Body=BodyOfFeed;
         
                    
         lstFeeds.add(fi);
        }
    }
   if(lstFeeds.size()>0){
         insert lstFeeds;
   }
  }
Now in the bold lines given above, if I add a topic that is of asingle word , it gets appended properly for eg  if Topic_1__c= "Sunshine" then post adds #Sunshine . But if Topic_1__c= "My Topic" post adds #My Topic to it. So how do we add muti word topis via apex. I found another link , but was not able to figure out much from this. Please help.

http://salesforce.stackexchange.com/questions/31163/how-to-add-topics-names-containing-spaces-to-feeditem-using-hashtag-via-apex?rq=1

Regards
Shrey Tyagi
Hi Everyone,
     I am taking baby steps towards REST apex  functionalliy and have developed some code (which fortunately woorks). Now I need your help in enhancing its operations. Please find the summary given below:

Using a json (given below) I managed to create an account record in salesforce:

{
   "acct":
   {
     "Name":"Jag"
   }

}

Apex Code:
@RestResource(urlMapping='/v1/accounts/*')
global with sharing class MyRestResource {
@HttpPost
    global static AccountWrapper doGet(Account acct) {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        AccountWrapper response= new Accountwrapper();
        try{
         insert acct;
         response.message='Mogamgo Khush Hua :)';
        }
        catch(Exception exc){
         response.message='Mogamgo Dukhi Hua :('; 
        }
       return response;
    }
      global class AccountWrapper {
      public Account acct;
      public String status;
      public String message;
      public AccountWrapper(){}

    }

}
Now I want to modify my apex code so that it can take a json with 1 account and 3 contacts in it and insert them in salesforce. Sample json is given below , can anyone please guide me with the modifications that are to be done in my apex class?


{
  "rqst":{
        "acct":{
         "Name":"Jag"
        }
        "conlist":{
         [
           {"FirstName":"Test","LastName":"Test"},
           {"FirstName":"Test1","LastName":"Test1"}
         ]
        }
  }

}
 
Hi Everyone,
          I am a newbie to Salesforce Integrations and I am reading a lot of stuff to get hang of how SOAP and REST integrations are done . I have few very basic questions related to patterns , if anyone can help me out with them , that would be great. Please find them given below:

Q1. For an inbound integration, we have 2 options (as per my knowledge). One is to create an apex class and expose it as a web service , so that it can be consumed by external entity (C# or Java platform). This code will be used in whatever DML operations  that are required . Second option is to ask the Java/C# side developers to write their own code and provide their code login access to salesforce by adding the application under remote side settings. How do we choose which approach to take? 

Q2. While making HTTP callouts to external systems , we usedifferent type of encoding like given below:

String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
String encodedPropAddress = EncodingUtil.urlEncode(Rec.a__c,'UTF-8');

How do we know which format is to be used when ? As in when to use base64 . Will it be provided to me as a salesforce developer by technicians of external systems (to which callouts are being made)?

I do know that these questions might sound to you as very basic ones , but I am bit confused . So I would really appriciate if someone can throw some light on them.

Thanks a lot for your help!!!

Regards
Shrey Tyagi
Hi All,
         I have this piece of code given below , Its a search page that displays results depending on search parametres and shows resuls with a checkbox next to them (Using Wrapper class). I wanna implement pagination here , Can anyone plz help me with the code?
Wrapper class line are highlighted.

public class AccountSearchController{

public List<Contact> ContactObjects {get;set;}
public List<Account> AccountObjects {get;set;}
public List<Account> AccountObjectsx {get;set;}
public Account AccObj {get;set;}
public Contact ContactObj {get;set;}
private String soql {get;set;}
//Our collection of the class/wrapper objects cContact 
public List<cContact> contactList {get; set;}
public ApexPages.StandardSetController con{get; set;}


////////////////////////////////////////////////////Constructor//////////////////////
public AccountSearchController(ApexPages.StandardController controller) {
  Value='Contact';
  ContactObj = new Contact();
  AccObj = new Account();
  // makes the defalut in the VF page for contact type as 'Main'
  ContactObj.Contact_Type__c ='Main';
  //pass value for picklist conatct type in query
  String slist = 'Main';
 
  // strings to pass defalut value of account segment and contact status and recordtype of account and contact as sales in query
  String defaultAccSegemnt= 'Regional';
  String defaultConStatus= 'Active';

  //list strings to pass account type in query as ('Active','Inactive','New')
  List <String> defaultAccType=new List<String>();
  String active= '\'Active\'';

  //userid = Userinfo.getUserId();
  userid='00550000000rgCd';
  system.debug('logged in user id>>>>>>>>>>'+ userid);
  
 
  soql ='SELECT Id,FirstName,LastName,Position__c,Contact.Account.IsPersonAccount,Contact.Account.Other_Address_Street_1__pc,Contact.Account.Phone ,Contact_Master_Policy_Mailing__c,Contact.Account.Type,Contact.Account.PY_Total_Ins_Volume__c,Contact_Type__c ,Phone,Email,Title, Contact.Account.Segment__c,Contact.Account.Parent_Name__c,Contact.Account.Branch_Org__c,Contact.Account.Name FROM Contact  ';

  runQuery();
 

}
public  PageReference runSearch() {
 
 

 
   Boolean masterPolicyBoolean=AccObj.Master_Policy__c;
  String masterPolicy;
  RecordType recordTypeValue= AccObj.RecordType;
  String recordType=String.valueof(recordTypeValue);

  if(Value == 'Contact'){
      soql ='SELECT Id,FirstName,LastName,Contact.Account.IsPersonAccount,Position__c,Contact.Account.Other_Address_Street_1__pc,Contact.Account.Phone,Contact_Master_Policy_Mailing__c,Contact.Account.Type,Contact.Account.PY_Total_Ins_Volume__c,Contact_Type__c ,Phone,Email,Title, Contact.Account.Parent_Name__c,Contact.Account.Segment__c,Contact.Account.Branch_Org__c,Contact.Account.Name FROM Contact WHERE  Contact.Account.Name!=null';
      soql += ' and Contact.Account.RecordTypeId =\''+String.escapeSingleQuotes(recordtypeAccount_sales)+'\'';
      soql += ' and Contact.RecordTypeId = \''+String.escapeSingleQuotes(recordtypeContact_sales)+'\'';
 
            if(AccountOwnerValue!=null && !AccountOwnerValue.equals('') && AccountOwnerValue.equals('My'))
                {soql += ' and Account.ownerId = \''+String.escapeSingleQuotes(userid)+'\'';
                system.debug('AccountOwnerValue soql -----------------------------'+AccountOwnerValue);
                system.debug('soql AccountOwnerValue -----------------------------'+soql );}


                }  
        }

                
   
  runQuery(); 
  return null;

}

public void runQuery() {


      soql+=  'Order By Contact.Account.Name';
          ContactObjects =Database.query(soql + ' limit 30');
          getContacts();
     

}

////////////////////////////Code Of Wrapper Class Starts here///////////

public List<cContact> getContacts() {
        system.debug('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
        //if(contactList == null) {
            contactList = new List<cContact>();
            for(Contact c:ContactObjects ) {
                // As each contact is processed we create a new cContact object and add it to the contactList
                contactList.add(new cContact(c));
            }
            
        // }
        return contactList;
    }
// This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value
public class cContact {
        public Contact con {get; set;}
        public Boolean selected {get; set;}
        //This is the contructor method. When we create a new cContact object we pass a Contact that is set to the con property. We also set the selected value to false
        public cContact(Contact c) {
        con = c;
        selected = false;
      }
}

public PageReference processSelected() {
    //We create a new list of Contacts that we be populated only with Contacts if they are selected
      List<Contact> selectedContacts = new List<Contact>();
      Set<Account> selectedAccounts = new Set<Account>();
      List<Account> selectedAccountList = new List<Account>();
      //We will cycle through our list of cContacts and will check to see if the selected property is set to true, if it is we add the Contact to the selectedContacts list
      //for(cContact cCon: gatContacts()) {
      for(cContact cCon: contactList) {
            if(cCon.selected == true) {
                selectedContacts.add(cCon.con);
                selectedAccounts.add(cCon.con.Account);
            }
        }
      // Now we have our list of selected contacts and can perform any type of logic we want, sending emails, updating a field on the Contact, etc
      for(Account acs: selectedAccounts){
          selectedAccountList.add(acs);
       }
       update selectedAccountList;
       update selectedContacts;
       contactList=null; // we need this line if we performed a write operation  because getContacts gets a fresh list now
       return null;
   }




     

}
Hi All ,
        I want to paginate a wrapper class such that when i navigate from one page to another the slected records dont get unchecked in previos page.
Code is goven below:

Apex:
public class wrapperClassController {
    //Our collection of the class/wrapper objects cContact
    public List<cContact> contactList {get; set;}
    public List<cContact> getContacts() {
        if(contactList == null) {
            contactList = new List<cContact>();
            for(Contact c: [select Id, Name, Email, Phone from Contact limit 10]) {
                // As each contact is processed we create a new cContact object and add it to the contactList
                contactList.add(new cContact(c));
            }
        }
        return contactList;
    }
    public PageReference processSelected() {
        List<Contact> selectedContacts = new List<Contact>();
        for(cContact cCon: getContacts()) {
            if(cCon.selected == true) {
                selectedContacts.add(cCon.con);
            }
        }
        for(Contact con: selectedContacts) {
            system.debug(con);

        }
        contactList=null; // we need this line if we performed a write operation  because getContacts gets a fresh list now
        return null;
    }
 
    public class cContact {
        public Contact con {get; set;}
        public Boolean selected {get; set;}
        public cContact(Contact c) {
            con = c;
            selected = false;
        }
    }
}
///////////////////////////////////////////////////////vf page////////////////////////////////////////////////////
<apex:page controller="wrapperClassController">




    <apex:form >




        <apex:pageBlock >




            <apex:pageBlockButtons >




                <apex:commandButton value="Process Selected" action="{!processSelected}" rerender="table"/>




            </apex:pageBlockButtons>




            <!-- In our table we are displaying the cContact records -->




            <apex:pageBlockTable value="{!contacts}" var="c" id="table">




                <apex:column >




                    <!-- This is our selected Boolean property in our wrapper class -->




                    <apex:inputCheckbox value="{!c.selected}"/>




                </apex:column>




                <!-- This is how we access the contact values within our cContact container/wrapper -->




                <apex:column value="{!c.con.Name}" />




                <apex:column value="{!c.con.Email}" />




                <apex:column value="{!c.con.Phone}" />




            </apex:pageBlockTable>




        </apex:pageBlock>




    </apex:form>



20
</apex:page>

Hi and thanks for reading this and for any help...

 

The requirement is to stop users from saving duplicate Team Member roles when they add or edit their Default Opportunity or Account Team.  

 

So, if Tom wants to add users to his default opp team, he can only add 1 "Sales Manager", 1 "Sales Lead", etc.

 

 

Eric

 

I need a javascript function that I can call from within a visualforce page that will make a call out to an external web service and return the result. The reason for this is that the result needs to be passed back to a calling javascript method rather than being rendered on the page.

What's the best way is acheive this?

- By using actionFunction and calling the actionFunction method from my proposed javascript method. I have attempted this option and the call out from the apex class method works fine but I'm not sure how to return the result to the calling javascript method. (i.e. I have a javascript method calling the actionFunction js method, passing in appropriate parameters, but unable to receive back a result.)

- Or by using Ajax Proxy? But was this designed for use within s-controls?

- Or any other suggestions gratefully received..

Message Edited by nelloC on 11-29-2009 12:28 PM
  • November 29, 2009
  • Like
  • 0