• Ranjeet Singh (SFDC Developer)
  • NEWBIE
  • 150 Points
  • Member since 2012

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 23
    Replies
Hi Team,
I am a beginner in salesforce.I have created a profile in salesforce.com.And I logged in  through java client application with that user name,password and security token. And I created sales force  users from my java application. How can they login without access sales force.Means they don't know about the
security token.They have only the user name and password. The sales force authentication  is only possible through my client application. My question is Is there any way to login without security token?
Hi folks,
My  custom object (Test) which contains (name ,phone number and email fields)and the records inside the test object only visible to the my team leader and his manager..other user,leader and manager cannot view those record in test objects. for that I've created Apex trigger:

trigger Test_Share on Test__c (after insert) {

Id i=UserInfo.getUserId();

//ID groupId = [select id from Group where Type = 'Organization'].id;

if(trigger.isInsert){

List<Test__Share> testShare= new List<Test__Share>();
     for(Test__c t : trigger.new){

        Test__Share ts = new Test__Share();


        ts.ParentId = t.Id;
        ts.UserOrGroupId = ParrentIdClass.getParrentId(i);



        ts.AccessLevel = 'edit';

        ts.RowCause = Schema.Test__Share.RowCause.Test_Access__c;
        testShare.add(ts);
    }
Database.SaveResult[] TestShareInsertResult = Database.insert(testShare,false);
}
}

Apex Class: public class ParrentIdClass {

public static Id getParrentId(Id i){
    String ParentUserName;
    Id ParentUserId;
    User u = new User(id=i);
    u = [select u.UserRoleId from User u where u.Id =: UserInfo.getUserId()];

    System.debug('UserRoleId='+u.UserRoleId);


    UserRole ur = new UserRole(id=u.UserRoleId);
  ur = [select ur.Id, ur.Name, ur.ParentRoleId from UserRole ur where ur.Id =: u.UserRoleId];


    System.debug('UrId='+ur.Id);
System.debug('UrName='+ur.Name);
System.debug('UrParentRoleId='+ur.ParentRoleId);


    if (ur.ParentRoleId != null){
        //  check if there's a ParentRole
      UserRole ur1 = new UserRole(id=ur.ParentRoleId);
      ur1 = [select ur1.Id, ur1.Name, ur1.ParentRoleId from UserRole ur1 where ur1.Id =: ur.ParentRoleId];
    System.debug('UrId='+ur1.Id);
  System.debug('UrName='+ur1.Name);
  System.debug('UrParentRoleId='+ur1.ParentRoleId);
      if(ur1.ParentRoleId != null){
          //  last level in the hierarchy
          UserRole ur2 = new UserRole(id=ur1.ParentRoleId);
          ur2 = [select ur2.Id, ur2.Name, ur2.ParentRoleId from UserRole ur2 where ur2.Id =: ur1.ParentRoleId];
          System.debug('UrId='+ur2.Id);
    System.debug('UrName='+ur2.Name);
    System.debug('UrParentRoleId='+ur2.ParentRoleId);
            ParentUserId=ur2.Id;
            return ParentUserId;
      }
         else{
          // no more ParentRoleId
          ParentUserId=ur1.Id;
           return ParentUserId;
        }
     }
    else{
      // no ParentRoleId
      ParentUserId=ur.Id;
        return ParentUserId;
  }
}
}

But it doesnt work for my scenario..

Please Help!
Hi, 

 I wrote a controller later it was used as a extension inside visualforce due to standardcontroller was used.
 
 Below is the Apex Class

 public class renewal_contract
{
    public renewal_contract(ApexPages.StandardController Cont ) {

    }
      
   String conId = ApexPages.currentPage().getParameters().get('Id');
  
    public List<Contract_Lines__c> Cont {get;set;}
    public renewal_contract()
    {
   
        Cont = [SELECT Serial_Number__c,
                       ContractLineNumber__c,
                       Service_Item_Description__c,
                       Service_Start_Date__c,
                       Service_End_Date__c,
                       Sub_Line_Status__c
                FROM Contract_Lines__c
                WHERE Contract__c = :conId ];
    }   
}


Visual force page to display values 

<apex:page sidebar="false" showheader="false"  standardController="contract"  extensions="renewal_contract">

<header>
<h1>Create Renewal Quote
</h1>
</header>
<br/><br/>

<b> Account Name  : </b>  {!Contract.Account.Name}
<br/><br/> 

<p> Existing Install base for <b> {!Contract.Account.Name} </b> </p>


<apex:pageBlock >
        <apex:pageBlockTable value="{!Cont}" var="c">
      
            <apex:column value="{!c.Contract__c}" />
            <apex:column value="{!c.Asset__c}"/>
            <apex:column value="{!c.Serial_Number__c}" />
            <apex:column value="{!c.Service_Item_Description__c}"/>
            <apex:column value="{!c.Date_Terminated__c}"/>
           
        </apex:pageBlockTable>
    </apex:pageBlock>




</apex:page>

Above visual force page is not displaying any values after chaning it to extensions please suggest me how to change

Thanks
Sudhir
This formula does work here for the State field:

IF(OR(ISBLANK(State)), "",
IF(CONTAINS("Hawaii:Alaska", State),"Pacific",
"")))


How do I add the COUNTRY field?  I want to add this line but the formula fails:

IF(CONTAINS("Australia:New Zeland", Country ), "APAC",
I have two fields "X" and "y" both are text fields.And i want these two fields to be concatenated in a required  text field called "name" in an object.Please help me..... 
  • September 09, 2014
  • Like
  • 1
Hi Team,
I am a beginner in salesforce.I have created a profile in salesforce.com.And I logged in  through java client application with that user name,password and security token. And I created sales force  users from my java application. How can they login without access sales force.Means they don't know about the
security token.They have only the user name and password. The sales force authentication  is only possible through my client application. My question is Is there any way to login without security token?
Hi All,

I have written Bulk Trigger to update date field based on the anothet date field on the same object. But my trigger is working for only first record only while inserting multiple records and for the rest of the records it is not updating.

Below is the code which i have used to update, not sure what wrong with my code and why it is not working for multiple records(bulk records). Please correct me if my code is wrong or if i have missed anything ???

Please reply if you find any sol.

Thanks a lot.
Ram

CODE:
trigger Update_PlannedShipmentDate on ccrz__E_OrderShipment__c (After insert, After Update) {

set<String> ccshipmentID= new set<String>();
List<ccrz__E_OrderShipment__c> shipmentList = New List<ccrz__E_OrderShipment__c>();

 
If(Recursion.isRecursion)
{
  system.debug('^^^^^^^ isRecursion:'+Recursion.isRecursion);
 
  For(ccrz__E_OrderShipment__c ccshipments : Trigger.New){
      ccshipmentID.add(ccshipments.id);
      system.debug('^^^^^^^ New SHipments:'+ccshipmentID);
  }
 
  system.debug('^^^^^^^ New SHipments:'+ccshipmentID);
  List<ccrz__E_OrderShipment__c> updateShipmentList = New List<ccrz__E_OrderShipment__c>();
  If(ccshipmentID.size() > 0 )
  {
     shipmentList = [select CCArq_Delivery_Time__c,Arq_Revised_Delivery_Date__c,Arq_Planned_Shipment_Date__c
                     FROM ccrz__E_OrderShipment__c
                     WHERE ID IN: ccshipmentID AND ccrz__Order__r.ccrz__Storefront__c ='ArqivaESales'];
     system.debug('^^^^^^^ Shipments list:'+shipmentList);
    
    
     For(ccrz__E_OrderShipment__c ccshipment : shipmentList )
     {
        if(ccshipment.CCArq_Delivery_Time__c != null && ccshipment.Arq_Revised_Delivery_Date__c == null)
        {
           ccshipment.Arq_Planned_Shipment_Date__c = date.newinstance(ccshipment.CCArq_Delivery_Time__c.year(), ccshipment.CCArq_Delivery_Time__c.month(), ccshipment.CCArq_Delivery_Time__c.day())- 5;
           updateShipmentList.add(ccshipment);
           system.debug('^^^^^^^ shipment:'+ccshipment);
        }
       else if(ccshipment.Arq_Revised_Delivery_Date__c != null)
        {
           ccshipment.Arq_Planned_Shipment_Date__c = ccshipment.Arq_Revised_Delivery_Date__c - 5;
           updateShipmentList.add(ccshipment);
           system.debug('^^^^^^^ update list:'+ccshipment);
        }
     }
    
      Recursion.isRecursion = false;
      system.debug('^^^^^^^ isRecursion:'+Recursion.isRecursion);
  }
  if(updateShipmentList.size() > 0){
          system.debug('^^^^^^^ update list:'+updateShipmentList);
          Update updateShipmentList;
         
   }
}

}
Hi folks,
My  custom object (Test) which contains (name ,phone number and email fields)and the records inside the test object only visible to the my team leader and his manager..other user,leader and manager cannot view those record in test objects. for that I've created Apex trigger:

trigger Test_Share on Test__c (after insert) {

Id i=UserInfo.getUserId();

//ID groupId = [select id from Group where Type = 'Organization'].id;

if(trigger.isInsert){

List<Test__Share> testShare= new List<Test__Share>();
     for(Test__c t : trigger.new){

        Test__Share ts = new Test__Share();


        ts.ParentId = t.Id;
        ts.UserOrGroupId = ParrentIdClass.getParrentId(i);



        ts.AccessLevel = 'edit';

        ts.RowCause = Schema.Test__Share.RowCause.Test_Access__c;
        testShare.add(ts);
    }
Database.SaveResult[] TestShareInsertResult = Database.insert(testShare,false);
}
}

Apex Class: public class ParrentIdClass {

public static Id getParrentId(Id i){
    String ParentUserName;
    Id ParentUserId;
    User u = new User(id=i);
    u = [select u.UserRoleId from User u where u.Id =: UserInfo.getUserId()];

    System.debug('UserRoleId='+u.UserRoleId);


    UserRole ur = new UserRole(id=u.UserRoleId);
  ur = [select ur.Id, ur.Name, ur.ParentRoleId from UserRole ur where ur.Id =: u.UserRoleId];


    System.debug('UrId='+ur.Id);
System.debug('UrName='+ur.Name);
System.debug('UrParentRoleId='+ur.ParentRoleId);


    if (ur.ParentRoleId != null){
        //  check if there's a ParentRole
      UserRole ur1 = new UserRole(id=ur.ParentRoleId);
      ur1 = [select ur1.Id, ur1.Name, ur1.ParentRoleId from UserRole ur1 where ur1.Id =: ur.ParentRoleId];
    System.debug('UrId='+ur1.Id);
  System.debug('UrName='+ur1.Name);
  System.debug('UrParentRoleId='+ur1.ParentRoleId);
      if(ur1.ParentRoleId != null){
          //  last level in the hierarchy
          UserRole ur2 = new UserRole(id=ur1.ParentRoleId);
          ur2 = [select ur2.Id, ur2.Name, ur2.ParentRoleId from UserRole ur2 where ur2.Id =: ur1.ParentRoleId];
          System.debug('UrId='+ur2.Id);
    System.debug('UrName='+ur2.Name);
    System.debug('UrParentRoleId='+ur2.ParentRoleId);
            ParentUserId=ur2.Id;
            return ParentUserId;
      }
         else{
          // no more ParentRoleId
          ParentUserId=ur1.Id;
           return ParentUserId;
        }
     }
    else{
      // no ParentRoleId
      ParentUserId=ur.Id;
        return ParentUserId;
  }
}
}

But it doesnt work for my scenario..

Please Help!
Hi folks,
           Can anyone tell me how to display the list of id values???
My apex class is:
public class ListIdValues{
    public static List<Id> IdValues(){
        list<Id> a=new list<Id>();
        a.add('00E90000000eytMEH1');
        a.add('00E90000000eytMEH1');
        a.add('00E90000000eytMEH1');
        a.add('00E90000000eytMEH1');
        a.add('00E90000000eytMEH1');
        return a;
    }
}
I tried like
List<id> lis=ListIdValues.IdValues();
for(Integer j=0;j<lis.size();j++)
    System.debug('list values='+ lis[j]);

how to display all the values in anonymous window??


Hi
Visualforce Code :
<apex:page controller="StringListEx" showheader="false" >
  <apex:form >
     <apex:pageblock >
        Name <apex:inputtext value="{!firVal}"/>
        code <apex:inputtext value="{!secVal}"/>
        Color <apex:inputtext value="{!thirdVal}"/>
        Class <apex:inputtext value="{!fourthVal}"/>
        <apex:commandButton value="Display" action="{!dislay}"/>
     </apex:pageblock>
  </apex:form>
</apex:page>
Apex/Controller Code :
public with sharing class StringListEx {

    public StringListEx (){
   
    } 
    
    public List<String> strLst;
    public String firVal { get; set; }
    public String secVal { get; set; }
    public String thirdVal { get; set; }
    public String fourthVal { get; set; }
    public PageReference dislay() {
        System.debug('First element value::::::::::::::'+firVal);
        System.debug('Second value::::::::::::::'+secVal);
        System.debug('Third value::::::::::::::::'+thirdVal);
        System.debug('Fourth value:::::::::::::::'+fourthVal); 
        strLst.add(firVal);   
        strLst.add(secVal);   
        strLst.add(thirdVal);   
        strLst.add(fourthVal);
        return null;
    }  
}

While Adding values to array,I'm getting this error System.NullPointerException: Attempt to de-reference a null object  at line 17.
In debugging I am getting the values whatever I entered
.Then why it is showing Nullpointer exception


I have created Detailed abutton and placed on the Task Record. The button should function like when we click the button a New opportunity page will opened and carry the data from Task to the Opportunity and need to display on Opportunity fields.  Below javascript created. But  it giving error like that    'Task.WhoId' is not exist like that. Please anyone correct bthis.




{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}

    var OpportunityCreate= new sforce.SObject("Opportunity");

OpportunityCreate.Contact_Name__c = '{!Task.WhoId}';


    var result = sforce.connection.create([OpportunityToCreate]);

    if (result[0].success == 'true')
    
   var newURL = '/' + result[0].id + '/e';
   window.top.location = newURL;
}
  • June 26, 2014
  • Like
  • 1
What can be the possible reason of recordsetvar not working. In my one developer edition recordsetvar is working and in second developer org  RECORDSETVAR  is not working .
So if anyone know the reason then tell me please.
Hi All,

I am kind of stuck with this inputField value attribute, can any one help me in finding this?

Actually I want to Limit the length of "Street" field to 30 characters. By searching online they suggested me to write Javascript function and write apex inputField instead of inputText but giving me error that value field is not an Sobject field.
Can any one please help me how to limit the text field to 30 characters? thank you so much in advance
Hi, 

 I wrote a controller later it was used as a extension inside visualforce due to standardcontroller was used.
 
 Below is the Apex Class

 public class renewal_contract
{
    public renewal_contract(ApexPages.StandardController Cont ) {

    }
      
   String conId = ApexPages.currentPage().getParameters().get('Id');
  
    public List<Contract_Lines__c> Cont {get;set;}
    public renewal_contract()
    {
   
        Cont = [SELECT Serial_Number__c,
                       ContractLineNumber__c,
                       Service_Item_Description__c,
                       Service_Start_Date__c,
                       Service_End_Date__c,
                       Sub_Line_Status__c
                FROM Contract_Lines__c
                WHERE Contract__c = :conId ];
    }   
}


Visual force page to display values 

<apex:page sidebar="false" showheader="false"  standardController="contract"  extensions="renewal_contract">

<header>
<h1>Create Renewal Quote
</h1>
</header>
<br/><br/>

<b> Account Name  : </b>  {!Contract.Account.Name}
<br/><br/> 

<p> Existing Install base for <b> {!Contract.Account.Name} </b> </p>


<apex:pageBlock >
        <apex:pageBlockTable value="{!Cont}" var="c">
      
            <apex:column value="{!c.Contract__c}" />
            <apex:column value="{!c.Asset__c}"/>
            <apex:column value="{!c.Serial_Number__c}" />
            <apex:column value="{!c.Service_Item_Description__c}"/>
            <apex:column value="{!c.Date_Terminated__c}"/>
           
        </apex:pageBlockTable>
    </apex:pageBlock>




</apex:page>

Above visual force page is not displaying any values after chaning it to extensions please suggest me how to change

Thanks
Sudhir

The documentation recommends that we use $CurrentPage.parameters rather than $Request in our Visualforce pages.

 

Is there any reason for this?

Just a quick question: How do I avoid urlencoding an ampersand (the '&' character). I wish to make a URI with parameters - the parameters are separated by ampersands, but they get encoded automatically (i.e., '&' goes to '&amp;'). 

 

The code looks like

 

<apex:iframe src="https://some-domain.com/action?a={!value1}&b={!value2}"/>

 

where value1 and value2 are attributes on my controller. The ampersand in between the two parameters is causing me trouble...

 

I would have expected that only application of the URLENCODE function would result in this substitution, but this is not the case. The '&' character is substituted without it.

 

All help is appreciated. Thank you!

  • September 27, 2012
  • Like
  • 0

Hi everybody,

 

My opportunity has a master-detail to a custom object called Opportunity.

i tried this

<apex:repeat value="{!Opportunity.Payment__c}" var="line"

 

but it's not working.

Anyone?

 

Hi,

 

My requirement is to have one search button in a VF page. And display the search results in a table with a checkbox for each record. Some records need to be selected and only those records have to be updated with some input value given on the same VF page.

 

The problem here is, first search button is working fine and displaying the results. But the update command button action is not getting invoked in the controller class.

 

Please find the code below.

 

This is very critical requorement which needs to be delivered.

 

 

It would be great if anyone could look into it and suggest.

 

VF PAGE:

 

<apex:page StandardController="User" id="thePage" Extensions="UserData">
  <apex:form >
  <apex:pageBlock title="SelectUsers" id="USERSLIST" mode="edit">
    <h1>Update Sales Co-ordinator for the users in Particular Region</h1>
  <br></br>
  <br></br>
   Select Region of the user:
    
   <apex:inputField id="startMode" value="{!User.Region__c}" />
   <br></br>
      <apex:commandButton action="{!doSearch}" value="Search" rerender="table">               
   </apex:commandButton>
  <br></br> 
  <apex:pageBlockSection >
   <apex:inputField value="{!User.ManagerId}" id="Manager"/>
  </apex:pageBlockSection> 
    
  <apex:pageBlockTable value="{!results}" var="t" id="table">
        <apex:column >
          <apex:inputCheckbox value="{!User.ManagerId}" id="checkedone">
          </apex:inputCheckbox>
        </apex:column>
        <apex:column value="{!t.Name}"/>
        <apex:column value="{!t.Email}"/>
        <apex:column value="{!t.Region__c}"/>
        <apex:column value="{!t.Manager__c}"/>
      
  </apex:pageBlockTable> 
    
  <apex:commandButton action="{!getSelected}" value="UpdateManager" />
  </apex:pageblock>    
  </apex:form>
  </apex:page>

 

CONTROLLER:

 

public class UserData {
List<Userwrapper> userList {get;set;}
PUBLIC String usr{get;set;}
PUBLIC List<selectOption> usrs;
List<User> results=new List<User>();
public User user;
  public UserData(ApexPages.StandardController controller)
   {
     this.user= (User)controller.getRecord();
   }
    
  public Pagereference doSearch()
     {
      results = [select Name,Region__c,Email,LanguageLocaleKey,Manager__c from User Where Region__c =:User.Region__c];
      system.debug('USERSLISTFOR REGION$$$$'+results);
      return null;
     }
  public List<Userwrapper> XXX() 
  {
     if(userList == null) {
      userList = new List<Userwrapper>();

     for(User u:results)
      {
        userList.add(new Userwrapper(u));
      }
      system.debug('****ADDEDUSERS****'+userlist);
       }
       return userList;

  }
    // This method is called for 'UpdateManager' command button action, which is not getting invoked when clicked on the button . 
   Public PageReference getSelected()
   {
        system.debug('ENTERED INTO SELECTED');
        List<User> selectedUsers = new List<User>();
        for(userwrapper usrwrapper : XXX())
        {
          if(usrwrapper.selected == true)
          {
           selectedusers.add(usrwrapper.wuser);
          }
        }
        system.debug('@@@SELECTEDUSERs@@@:'+selectedusers); 
        return null;
  }
  
   Public Pagereference UpdateManager()
   {
        return null;
   }
      
   public List<User> getResults()
    {
        return results;
    }
 
 }

Hi Guys....

 

I have custom field in lead called club_name__c which is lookup to Account. i need to map this field into Contact's Accont name field which is also lookup to Account .

that means when i filled the club_name__c in lead and hit on convert button then it will converted to contact and Contact's Account Name filled will be autopopulate whatever i filled in lead..

Any help..

 

Thanks in Advance...

  • September 24, 2012
  • Like
  • 0