• ExploreForce
  • NEWBIE
  • 9 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 10
    Replies
trigger OpportunityBeforeUpdate on Opportunity (before update) {

    //Update Account Global account
  
    List<Opportunity> listOpp = new List<Opportunity>();
    
       if(trigger.isBefore)
      {
      
         if(Trigger.isUpdate)
         {
         
            for(Opportunity fOpp: trigger.new)
               {
                 if(fOpp.StageName != trigger.oldmap.get(fOpp.Id).StageName)
                     listOpp.add(fOpp);
               }
         
         }
      }
      
        //list<PermissionSet> lstPermissionSets=[Select Name,Id From PermissionSet where Name='Opportunity_Users_Permission_sets'];
        list<PermissionSetAssignment> lstPermSets=[select PermissionSet.Name from PermissionSetAssignment
                                                   where Assignee.Id = :UserInfo.getUserId()
                                                   AND PermissionSet.Name='Opportunity_Users_Permission_sets'];
       system.debug('>>>>>>>lstPermSets>>>>'+lstPermSets);    
       if(lstPermSets.size()>0 && listOpp.size()>0)
       {
           
           Opportunity nOpp=[select Id,SkipStage__c,StageName from Opportunity where Id=:listOpp];
           system.debug('>>>>>>>Opportunity STAGE CHNAGE>>>>');
           //nOpp.SkipStage__c= true;--I need to set(boolean) this to true to skip validation.
           //update nOpp; 
       
       }


Please anyone can suggest, how to skip validtion rule for users in permissionsets .
 Return list of potential contact based on
===========================================================================
1. derived email .@example.com-->(firstname+lastname@example.com)
2. and first initial of first name and full last name.(firstname(firstinitial) and lastname='fullname')
3. email provided on recruiting contact (email on contact)
====================================================================
contactList = [Select c.Id,c.My_Key_Partner__c,c.FirstName,c.LastName,c.Name,c.Email,
                                c.My_Contact__c,c.RD_Contact__c, c.User__c, c.RecordTypeId,
                                c.OwnerId, c.Owner.ManagerId
                                From Contact c
                                Where c.Id = : recontactId
                                or c.email=c.FirstName+c.LastName+'@scotiabank.com'
                                or c.FirstName= 'A%'  and c.LastName='%'
                                or c.email='%@%.com'];



Please help:
Thanks
Hi,
I have to fetch Account.Preferred_Greeting__pc for each CampaignMamber. Please can one suggest, how to get value from Account??
 
for(CampaignMember cm : campMembers)
        {
            list<Account> lstCon=[SELECT Id,Preferred_Greeting__pc FROM Account WHERE Id=:cm.Contact.Id];
            string html = emailHTML.replace('{!cwGreeting}', this.greeting+' '+lstCon[0].Preferred_Greeting__pc+',');
            }
Hi,

I have  Parent obj:Products__c  and child obj:Imagaes__c.
     
       Map<Id,list<Imagaes__c>> mapofImagaes=new Map<Id,list<Imagaes__c>>();
       /* list<Imagaes__c> lstImages = new list<Imagaes__c>();
        for(Products__c xPrd:listRauPrds1)
         {
           // lstImages.clear();
           for(Imagaes__c rImg:xPrd.Images__r)
           {
                   //create a map
                   lstImages.add(rImg);
                   mapofImagaes.put(xPrd.id, lstImages);
         
                
           }
        
           
          
          }*/

In the above code, I m trying to create a map which holds first three images of Product1..so on.
Basically,I have to display three images of Product in my email template.
Pls can anyone suggest, how to create MAP ?So, that I can fetch map and display Images.
I have a scenario where, I want to populate LOOKUP field based on <apex:selectionlist>

Example:
<apex:outputLabel for="attribute-search-status" value="Categories"/>
            <apex:outputPanel styleClass="requiredInput" layout="block" >
             <apex:outputPanel styleClass="requiredBlock" layout="block"/>
                  <apex:selectList id="theform" value="{!selectedCategory}" size="1" required="true" style="width:180px" >
                <apex:selectOptions value="{!Categories}" />
                <!--<apex:actionSupport event="onchange" action="{!createServiceAgreement}" reRender="pg"/>-->
                <!--<apex:actionFunction name="createServiceAgreement" action="{!createServiceAgreement}" reRender="panel"/>
                <apex:actionSupport event="onchange"/>-->
              </apex:selectList>        
              </apex:outputPanel>

And my lookup field is :

<apex:inputField id="panel" value="{!ReqUser.ServiceAgreement__c}" required="true"/>


I tried couple of solutions using:

<apex:actionFunction name="createServiceAgreement" action="{!createServiceAgreement}" reRender="panel"/>
and there is no solution.


1..Is that really possible to populate LOOKUP field based on selectionlist using <APEX:ACTIONFUNCTION>???
or 2.Have to only Trigger in such scenario??

Pls help. 
<apex:page standardController="Request__c" extensions="LocationRequestController" sidebar="false">
<apex:form id="theform">
    <apex:pagemessages id="errorMessage"/>
    <apex:pageBlock >
    <apex:pageBlockButtons location="top">
        <apex:commandButton status="statusId" value="Save" action="{!Save}" />
        <apex:commandButton status="statusId" value="Save & Create Order" action="{!SaveAndCreateOrder}" />
        </apex:pageBlockButtons>
        <apex:pageBlockSection id="Atts">
      <apex:pageBlockSectionItem >
            <apex:outputLabel for="attribute-search-status" value="User"/>
            <apex:outputPanel styleClass="requiredInput" layout="block" >
             <apex:outputPanel styleClass="requiredBlock" layout="block"/>
              <apex:selectList id="attribute-search-status" value="{!selectedUser}" required="true" size="1" style="width:180px">
                <apex:selectOptions value="{!Users}"/>
              </apex:selectList>  
              </apex:outputPanel>   
            </apex:pageBlockSectionItem>
          
       <apex:inputField value="{!ReqUser.Location__c}" required="true"/>
      
             <apex:pageBlockSectionItem >
              <apex:outputLabel for="attribute-search-status" value="Categories"/>
            <apex:outputPanel styleClass="requiredInput" layout="block" >
             <apex:outputPanel styleClass="requiredBlock" layout="block"/>
              <apex:selectList id="attribute-search-status" value="{!selectedCategory}" size="1" required="true" style="width:180px">
                <apex:selectOptions value="{!Categories}"/>
              </apex:selectList>        
              </apex:outputPanel>   
            </apex:pageBlockSectionItem>
      
            <!--<apex:actionFunction action="{!createServiceAgreement}" name="pServiceAgreement" reRender="pServAgreement" />-->
           <apex:inputField value="{!ReqUser.ServiceAgreement__c}" required="true"/>
         
            </apex:pageBlockSection>
         </apex:pageblock> 
       
   </apex:form>    
</apex:page>

I need to populate : <apex:inputField value="{!ReqUser.ServiceAgreement__c}" required="true"/> based on below fields:
Location__c and Categories
How to use <apex:actionfunction>.Pls help

           <apex:inputField value="{!ReqUser.Location__c}" required="true"/>
     
             <apex:pageBlockSectionItem >
              <apex:outputLabel for="attribute-search-status" value="Categories"/>
            <apex:outputPanel styleClass="requiredInput" layout="block" >
             <apex:outputPanel styleClass="requiredBlock" layout="block"/>
              <apex:selectList id="attribute-search-status" value="{!selectedCategory}" size="1" required="true" style="width:180px">
                <apex:selectOptions value="{!Categories}"/>
              </apex:selectList>       
              </apex:outputPanel>  
            </apex:pageBlockSectionItem>

I need to populate : <apex:inputField value="{!ReqUser.ServiceAgreement__c}" required="true"/> based on below fields.
How to use <apex:actionfunction>.Pls help
If i have two VF pages,
<apex:page standardController="Request__c" extensions="LocationRequestController" sidebar="false"> and
AND

<apex:page standardController="Order" extensions="LocationRequestController" sidebar="false">.

Controller:

public LocationRequestController(ApexPages.StandardController controller) {
       
        AccId= ApexPages.currentPage().getParameters().get('AccId');
   if(object==Request__c)
        {
        system.debug('AccId'+ AccId);
        ReqUser=(Request__c) controller.getRecord();
        ReqUser.Location__c=AccId;
        brequest=true;
       
        }
        else
        {
         OrderReq=(Order) controller.getRecord();
         OrderReq.AccountId=AccId;
         blorder=true;
        }
}
Is this allowed in salesforce?
IS there any way i can differentiate, based on object?
insert reqUser is throwing error:User not inserted.How to populate it from below code.
Pls help.

Vf page:

<apex:page standardController="Request__c" extensions="LocationRequestController" sidebar="false">
<apex:form id="theform">
    <apex:pagemessages id="errorMessage"/>
    <apex:pageBlock >
    <apex:pageBlockButtons location="top">
        <apex:commandButton status="statusId" value="Save" action="{!Save}" />
        </apex:pageBlockButtons>
        <apex:pageBlockSection id="atts">
      <apex:pageBlockSectionItem >
            <apex:outputLabel for="ReqUser" value="User"/>
              <apex:selectList id="ReqUser" value="{!usersOption}" size="1">
                <apex:selectOptions value="{!Users}"/>
              </apex:selectList>     
            </apex:pageBlockSectionItem>

</apex:pageBlockSection>
         </apex:pageblock>
      
   </apex:form>   
</apex:page>



Controller:


public with sharing class LocationRequestController {
public Request__c ReqUser{get; set;}
public Order OrderReq{get; set;}
private string AccId{get; set;}

 
    public LocationRequestController(ApexPages.StandardController controller) {
       
         AccId= ApexPages.currentPage().getParameters().get('AccId');
         system.debug('AccId'+ AccId);
         ReqUser=(Request__c) controller.getRecord();
         ReqUser.Location__c=AccId;
         //OrderReq=(Order) controller.getRecord();
       
    }
   
   
  
     public string usersOption{get;set;}
     public List<SelectOption> getUsers() {
                list<SelectOption> optionList = new list<SelectOption>();
                List<Contact> usrList = [Select Id,Name From Contact where AccountId=:AccId];
                for(Contact xUsr: usrList)
                {
                        optionList.add(new SelectOption(xUsr.Id,xUsr.Name));
                }
              
                return optionList;
        }
public pageReference Save() {
    
      insert ReqUser;
}
<div class="container">
      <div class="row clearfix">
        <div class="col-md-12 column">
          <apex:form styleClass="navbar-form navbar-left">
            <div class="form-group">
                <label for="PropAddress">Find out how it affects you</label>
                <c:Typeahead styleclass="form-control" object="Service_Address__c"  id="PropAddress" placeholder="Please type your address" destinationForSelectedId="propertyId"/>
               
              </div>

              <apex:inputHidden id="propertyId" value="{!propertyId}" /> 

              <apex:commandButton value="Find" styleClass="btn-primary" action="{!DisplayProperty}"/>
          </apex:form>


        </div>
      </div>
    </div>



User-added image
<apex:pageBlock ><apex:pageblockSection ><apex:pageBlockSectionItem >
                     <apex:inputText styleClass="form-control" id="email" value="{!email}" style="width:400px"/>
                     <!--<apex:inputText styleClass="input-medium" id="email" value="{!email}"/>-->
                     <apex:commandButton value="Confirm" styleClass="btn-primary" action="{!UpdateCart}" style="background:orange"/>
                     <!-- <input type="email" class="form-control" id="exampleInputEmail1"> </input>-->
                     </apex:pageBlockSectionItem></apex:pageblockSection></apex:pageBlock>

 I want a textbox and commandbutton on same line. How to achive this without using <apex:pageblock>?
Please help!!
 
Trigger is thrwing this error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated
a non-setup object (or vice versa)

trigger PODGroupMemberBeforeInsert on Pod_Group_Member__c (before insert) {

//Map<String,GroupMember> lstGrpMembers=new Map<String,GroupMember>();
set<Id> lstGrpMembers=new set<Id>();
List<Pod_Group_Member__c> podGroupMembers = new List<Pod_Group_Member__c>();

for(GroupMember xGm:[Select UserOrGroupId, GroupId From GroupMember where Group.Name = 'Non-Pod Members'])
{
     lstGrpMembers.add(xGm.UserOrGroupId);
}

system.debug(lstGrpMembers);
User aUser = [SELECT id FROM User WHERE Id = :UserInfo.getUserId()];
list<Id> lstgm = new list<Id>();
for(Pod_Group_Member__c xPod: Trigger.new) {
 
      if(lstGrpMembers.contains(xPod.Pod_Member__c))
      {
         //add to list
         lstgm.add(xPod.Pod_Member__c);
        
      }  
          Pod_Group_Member__c podGrp= new Pod_Group_Member__c();
          //podGrp.Pod_Group__c=
          podGrp.Pod_Member__c = aUser.Id;
          podGroupMembers.add(podGrp);
}  
     if(lstgm.size()>0)
      {
         list<GroupMember> lstg=[select UserOrGroupId, GroupId From GroupMember where UserOrGroupId=:lstgm]; 
         delete lstg;
        
      }
   database.insert(podGroupMembers,false);
     

}

Pls suggest solution!
Based on the picklist value selected for user, GrpMem should retain only that user and corresponding group.
And remove the other groups associated with that user.
Any idea to improve this?

global without sharing class UsrGrpClass {

  public void UsergroupMethod(List<User> usr)
  {
    list<String> listGroups = new list<String>();
    Map<String,Group> mapGrp = new Map<String,Group>();
    Schema.DescribeFieldResult fieldResult =  User.User_Group__c.getDescribe();
    List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
  
    for(Schema.PicklistEntry f : ple){
      listGroups.add(f.getlabel());
    }
    
    List<String> sGroupIds = new List<String>();
    list<Group> listGrp = [Select Id,DeveloperName,Name From Group where Type = 'Regular' And Name = :listGroups];
    system.debug(listGrp);
    for(Group g:listGrp)
    {
       sGroupIds.add(g.id);
    }
  
    //Get all group names and users based on the groupids in picklist
    Set<Id> userId = new Set<Id>();
    List<GroupMember> delGroupIds = new List<GroupMember>();
    map<string, list<Id>> groupNameUserMapping = new map<string, list<Id>>();
    List<GroupMember> listGrpm = [SELECT Id, group.name,userorGroupId  FROM GroupMember where userorGroupId IN:sGroupIds];
                                   //where (UserOrGroupId IN :sGroupIds AND group.type='Regular')];
    system.debug(listGrpm);

    //Get all the group names and Users based on User record
    List<user> userRecord = (List<user>)ousr;
    List<GroupMember> listgroup = [Select Id,group.name,userorGroupId from GroupMember where userorGroupId IN:userRecord];
    system.debug(listgroup);
    List<String> sGroupMemIds = new List<String>();
    List<String> sGroupNames = new List<String>();
    //Set<Id> sGroupMemIds = new Set<Id>();
    for(GroupMember gpm :listgroup)
    {
        sGroupMemIds.add(gpm.userorGroupId);
        sGroupNames.add(gpm.group.name);
    }
  
  
 
    //Traverse through the groupmembers
    for(GroupMember gm:listGrpm)
    {
  
        if(sGroupMemIds.equals(gm.userorGroupId) && sGroupNames.equals(gm.group.name))
        {
               //Retain user
       }
        else
        {
               delGroupIds.add(gm);
        
        }
         userId.add(gm.userOrGroupId);
    }

    If(delGroupIds.size() > 0)
            delete delGroupIds;

}

}
How to write batch job?

Batch job should look through all GroupMember table
if one user is in multlipe group, it should remove users from other groups


Hi,

I have class for which I am facing small issue to cover my test class:

             //My controller class where I am creating ContentDocumntLink

             ContentDocumentLink newFileShare = new ContentDocumentLink();
                newFileShare.ContentDocumentId = listsfa[0].Secured_Files__r.Content_Document_Id__c;
                newFileShare.LinkedEntityId = fileSt.User__c;
                if(fileSt.Requested_Access_Type__c == 'Read')
                     newFileShare.ShareType= 'V';
                else if(fileSt.Requested_Access_Type__c == 'Read/Write')
                    newFileShare.ShareType= 'C';
                listContentShares.add(newFileShare);
                insert listContentShares;


   ***************************************************************************************  

   //TEST CLASS Coverage code

        string before = 'Testing base 64 encode';            
         Blob beforeblob = Blob.valueOf(before);
         //Insert contentdocument data
         ContentVersion cv = new ContentVersion();
         cv.title = 'test content trigger';      
         cv.PathOnClient ='test';           
         cv.VersionData =beforeblob;          
         insert cv;         
                                                
         ContentVersion testContent = [SELECT id, ContentDocumentId FROM ContentVersion where Id = :cv.Id];

        ContentDocumentLink newFileShare = new ContentDocumentLink();
        newFileShare.contentdocumentid = testcontent.contentdocumentid;
        newFileShare.LinkedEntityId = fileSt.User__c;
        newFileShare.ShareType= 'V';
        insert newFileShare;


     In the first attemp I tried with the above SQL query and I m getting below error:

     System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, You cannot create a link for a document in a personal library: [ContentDocumentId]

 
To resolve the above error: I have come up with solution ,

       ContentWorkspace testWorkspace = [SELECT Id FROM ContentWorkspace limit 1];
         ContentWorkspaceDoc newWorkspaceDoc =new ContentWorkspaceDoc();
         newWorkspaceDoc.ContentWorkspaceId = testWorkspace.Id;
         newWorkspaceDoc.ContentDocumentId = testContent.ContentDocumentId;
         insert newWorkspaceDoc;

  It's throwing error:
   System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.: [ContentWorkspaceId]



Please help!!
In the application, I need to automatically “archive” an event once it becomes 3 months old by setting its status to “Archived”
What is the best way and how to achieve this?
Pls help!

I have written a trigger to automate deletion process if user checks the checkbox.

trigger checkCheckBox on Registration__c(after update) {
    //List to contain Registration(s) to be deleted.
    Registration__c[] toBeDeleted = new list<Registration__c>();

    for (Registration__c Register : Trigger.new) {
       if (Register.Registration_cancel__c== True) {
          toBeDeleted.add(Register);
       }
    }
    delete toBeDeleted;
}

The above code sample is throwing following exception:

caused by: System.SObjectException: DML statment cannot operate on trigger.new or trigger.old
Trigger.deleteDeletedOrgs: line 10, column 1.

How to resolve this?
I want to quickly see how many people are registered for an event and the total number of sessions for an event on the event
detail screen.
I am new to sealesforce.Pls provide some ideas?

I want to create insert trigger on registration.
1. create lookup on contacts
2. Need to check whether email id already exists in contacts.
     if emailid alreday exists in contacts, Don''t register
     if emailid doesn't exist, then register the user with new mailid.
     
     Can someone help on this?

      trigger Registration on Registration__c (before insert) {
      List<String>newemail = new List<String>();
      List<Contact> parentObjList = new List<Contact>();
       List<Id> listIds = new List<Id>();

    for (Registration__c childObj : Trigger.new) {
        listIds.add(childObj.Contact__c);
    }

    parentObjList = [SELECT id,email FROM Contact WHERE ID IN :listIds];
}
 Return list of potential contact based on
===========================================================================
1. derived email .@example.com-->(firstname+lastname@example.com)
2. and first initial of first name and full last name.(firstname(firstinitial) and lastname='fullname')
3. email provided on recruiting contact (email on contact)
====================================================================
contactList = [Select c.Id,c.My_Key_Partner__c,c.FirstName,c.LastName,c.Name,c.Email,
                                c.My_Contact__c,c.RD_Contact__c, c.User__c, c.RecordTypeId,
                                c.OwnerId, c.Owner.ManagerId
                                From Contact c
                                Where c.Id = : recontactId
                                or c.email=c.FirstName+c.LastName+'@scotiabank.com'
                                or c.FirstName= 'A%'  and c.LastName='%'
                                or c.email='%@%.com'];



Please help:
Thanks
<apex:page standardController="Request__c" extensions="LocationRequestController" sidebar="false">
<apex:form id="theform">
    <apex:pagemessages id="errorMessage"/>
    <apex:pageBlock >
    <apex:pageBlockButtons location="top">
        <apex:commandButton status="statusId" value="Save" action="{!Save}" />
        <apex:commandButton status="statusId" value="Save & Create Order" action="{!SaveAndCreateOrder}" />
        </apex:pageBlockButtons>
        <apex:pageBlockSection id="Atts">
      <apex:pageBlockSectionItem >
            <apex:outputLabel for="attribute-search-status" value="User"/>
            <apex:outputPanel styleClass="requiredInput" layout="block" >
             <apex:outputPanel styleClass="requiredBlock" layout="block"/>
              <apex:selectList id="attribute-search-status" value="{!selectedUser}" required="true" size="1" style="width:180px">
                <apex:selectOptions value="{!Users}"/>
              </apex:selectList>  
              </apex:outputPanel>   
            </apex:pageBlockSectionItem>
          
       <apex:inputField value="{!ReqUser.Location__c}" required="true"/>
      
             <apex:pageBlockSectionItem >
              <apex:outputLabel for="attribute-search-status" value="Categories"/>
            <apex:outputPanel styleClass="requiredInput" layout="block" >
             <apex:outputPanel styleClass="requiredBlock" layout="block"/>
              <apex:selectList id="attribute-search-status" value="{!selectedCategory}" size="1" required="true" style="width:180px">
                <apex:selectOptions value="{!Categories}"/>
              </apex:selectList>        
              </apex:outputPanel>   
            </apex:pageBlockSectionItem>
      
            <!--<apex:actionFunction action="{!createServiceAgreement}" name="pServiceAgreement" reRender="pServAgreement" />-->
           <apex:inputField value="{!ReqUser.ServiceAgreement__c}" required="true"/>
         
            </apex:pageBlockSection>
         </apex:pageblock> 
       
   </apex:form>    
</apex:page>

I need to populate : <apex:inputField value="{!ReqUser.ServiceAgreement__c}" required="true"/> based on below fields:
Location__c and Categories
How to use <apex:actionfunction>.Pls help

           <apex:inputField value="{!ReqUser.Location__c}" required="true"/>
     
             <apex:pageBlockSectionItem >
              <apex:outputLabel for="attribute-search-status" value="Categories"/>
            <apex:outputPanel styleClass="requiredInput" layout="block" >
             <apex:outputPanel styleClass="requiredBlock" layout="block"/>
              <apex:selectList id="attribute-search-status" value="{!selectedCategory}" size="1" required="true" style="width:180px">
                <apex:selectOptions value="{!Categories}"/>
              </apex:selectList>       
              </apex:outputPanel>  
            </apex:pageBlockSectionItem>

I need to populate : <apex:inputField value="{!ReqUser.ServiceAgreement__c}" required="true"/> based on below fields.
How to use <apex:actionfunction>.Pls help
If i have two VF pages,
<apex:page standardController="Request__c" extensions="LocationRequestController" sidebar="false"> and
AND

<apex:page standardController="Order" extensions="LocationRequestController" sidebar="false">.

Controller:

public LocationRequestController(ApexPages.StandardController controller) {
       
        AccId= ApexPages.currentPage().getParameters().get('AccId');
   if(object==Request__c)
        {
        system.debug('AccId'+ AccId);
        ReqUser=(Request__c) controller.getRecord();
        ReqUser.Location__c=AccId;
        brequest=true;
       
        }
        else
        {
         OrderReq=(Order) controller.getRecord();
         OrderReq.AccountId=AccId;
         blorder=true;
        }
}
Is this allowed in salesforce?
IS there any way i can differentiate, based on object?
insert reqUser is throwing error:User not inserted.How to populate it from below code.
Pls help.

Vf page:

<apex:page standardController="Request__c" extensions="LocationRequestController" sidebar="false">
<apex:form id="theform">
    <apex:pagemessages id="errorMessage"/>
    <apex:pageBlock >
    <apex:pageBlockButtons location="top">
        <apex:commandButton status="statusId" value="Save" action="{!Save}" />
        </apex:pageBlockButtons>
        <apex:pageBlockSection id="atts">
      <apex:pageBlockSectionItem >
            <apex:outputLabel for="ReqUser" value="User"/>
              <apex:selectList id="ReqUser" value="{!usersOption}" size="1">
                <apex:selectOptions value="{!Users}"/>
              </apex:selectList>     
            </apex:pageBlockSectionItem>

</apex:pageBlockSection>
         </apex:pageblock>
      
   </apex:form>   
</apex:page>



Controller:


public with sharing class LocationRequestController {
public Request__c ReqUser{get; set;}
public Order OrderReq{get; set;}
private string AccId{get; set;}

 
    public LocationRequestController(ApexPages.StandardController controller) {
       
         AccId= ApexPages.currentPage().getParameters().get('AccId');
         system.debug('AccId'+ AccId);
         ReqUser=(Request__c) controller.getRecord();
         ReqUser.Location__c=AccId;
         //OrderReq=(Order) controller.getRecord();
       
    }
   
   
  
     public string usersOption{get;set;}
     public List<SelectOption> getUsers() {
                list<SelectOption> optionList = new list<SelectOption>();
                List<Contact> usrList = [Select Id,Name From Contact where AccountId=:AccId];
                for(Contact xUsr: usrList)
                {
                        optionList.add(new SelectOption(xUsr.Id,xUsr.Name));
                }
              
                return optionList;
        }
public pageReference Save() {
    
      insert ReqUser;
}
<div class="container">
      <div class="row clearfix">
        <div class="col-md-12 column">
          <apex:form styleClass="navbar-form navbar-left">
            <div class="form-group">
                <label for="PropAddress">Find out how it affects you</label>
                <c:Typeahead styleclass="form-control" object="Service_Address__c"  id="PropAddress" placeholder="Please type your address" destinationForSelectedId="propertyId"/>
               
              </div>

              <apex:inputHidden id="propertyId" value="{!propertyId}" /> 

              <apex:commandButton value="Find" styleClass="btn-primary" action="{!DisplayProperty}"/>
          </apex:form>


        </div>
      </div>
    </div>



User-added image
<apex:pageBlock ><apex:pageblockSection ><apex:pageBlockSectionItem >
                     <apex:inputText styleClass="form-control" id="email" value="{!email}" style="width:400px"/>
                     <!--<apex:inputText styleClass="input-medium" id="email" value="{!email}"/>-->
                     <apex:commandButton value="Confirm" styleClass="btn-primary" action="{!UpdateCart}" style="background:orange"/>
                     <!-- <input type="email" class="form-control" id="exampleInputEmail1"> </input>-->
                     </apex:pageBlockSectionItem></apex:pageblockSection></apex:pageBlock>

 I want a textbox and commandbutton on same line. How to achive this without using <apex:pageblock>?
Please help!!
 
Hi,

I have class for which I am facing small issue to cover my test class:

             //My controller class where I am creating ContentDocumntLink

             ContentDocumentLink newFileShare = new ContentDocumentLink();
                newFileShare.ContentDocumentId = listsfa[0].Secured_Files__r.Content_Document_Id__c;
                newFileShare.LinkedEntityId = fileSt.User__c;
                if(fileSt.Requested_Access_Type__c == 'Read')
                     newFileShare.ShareType= 'V';
                else if(fileSt.Requested_Access_Type__c == 'Read/Write')
                    newFileShare.ShareType= 'C';
                listContentShares.add(newFileShare);
                insert listContentShares;


   ***************************************************************************************  

   //TEST CLASS Coverage code

        string before = 'Testing base 64 encode';            
         Blob beforeblob = Blob.valueOf(before);
         //Insert contentdocument data
         ContentVersion cv = new ContentVersion();
         cv.title = 'test content trigger';      
         cv.PathOnClient ='test';           
         cv.VersionData =beforeblob;          
         insert cv;         
                                                
         ContentVersion testContent = [SELECT id, ContentDocumentId FROM ContentVersion where Id = :cv.Id];

        ContentDocumentLink newFileShare = new ContentDocumentLink();
        newFileShare.contentdocumentid = testcontent.contentdocumentid;
        newFileShare.LinkedEntityId = fileSt.User__c;
        newFileShare.ShareType= 'V';
        insert newFileShare;


     In the first attemp I tried with the above SQL query and I m getting below error:

     System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, You cannot create a link for a document in a personal library: [ContentDocumentId]

 
To resolve the above error: I have come up with solution ,

       ContentWorkspace testWorkspace = [SELECT Id FROM ContentWorkspace limit 1];
         ContentWorkspaceDoc newWorkspaceDoc =new ContentWorkspaceDoc();
         newWorkspaceDoc.ContentWorkspaceId = testWorkspace.Id;
         newWorkspaceDoc.ContentDocumentId = testContent.ContentDocumentId;
         insert newWorkspaceDoc;

  It's throwing error:
   System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.: [ContentWorkspaceId]



Please help!!
I want to create insert trigger on registration.
1. create lookup on contacts
2. Need to check whether email id already exists in contacts.
     if emailid alreday exists in contacts, Don''t register
     if emailid doesn't exist, then register the user with new mailid.
     
     Can someone help on this?

      trigger Registration on Registration__c (before insert) {
      List<String>newemail = new List<String>();
      List<Contact> parentObjList = new List<Contact>();
       List<Id> listIds = new List<Id>();

    for (Registration__c childObj : Trigger.new) {
        listIds.add(childObj.Contact__c);
    }

    parentObjList = [SELECT id,email FROM Contact WHERE ID IN :listIds];
}