• Soumyodeep Guha 8
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 3
    Replies
HI All,

can anyone let me know on how can we upload files from salesfore to sharepoint?
and if possble also let me know the steps for the same

Thanks 
HI All,

can anyone provide me a solution on how to update the ownerId field in the ContentDocument object. i have tried doing this with a trigger on ContentDocument object but it does not seems to work
HI All,

i have a requrement where access to particular version of a file needs to be removed based on a condition.
Example if there are 3 version of a file then say access to version 2 needs to be removed, is this possible somehow using the ContentVersion object?
HI All,

i have written the below trigger on the ContentDocument object for a Before Insert scenerio, but the trigger seems not to be firing.
Can anyone help me with this, below is my code

Trigger
trigger ContentDocumentTrigger on ContentDocument (Before Insert) {
    if(trigger.isInsert && trigger.isBefore){
        fileSharing.publicGroupOwnership1(trigger.new);
    }
}

Handler class
public without sharing class fileSharing{
    
    public static void publicGroupOwnership1 (list<ContentDocument> ContentDocumentRcd){
        
        profile adminProfile = [Select id from profile where name='System Administrator'];        
        user adminUser = [Select id, name from user where profileId=:adminProfile.id];
        
        for(ContentDocument ContentDocumentLoop :ContentDocumentRcd){
            
            ContentDocumentLoop.OwnerId = adminUser.Id;
        }
        system.debug('$$contentDocumentRcd '+contentDocumentRcd);
    }
}
HI All,
i need some help
i am stuck at there part where i am not able to save the data from the page to the database, and the strange part is, that with my below code i am able to clear the challange
below is my code 

CampingList.cmp
<aura:component controller="CampingListController">
    
    <aura:attribute name="items" type="Camping_Item__c[]"/>
    <aura:attribute name="newItem" type="Camping_Item__c" default="{'Name':'',
                                                                   'Quantity__c':0,
                                                                   'Price__c':0,
                                                                   'Packed__c':false,
                                                                   'sobjectType':'Camping_Item__c'}"/>
  <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    
    <c:campingHeader />
    
    <!-- NEW Item entry FORM -->
    <lightning:layout >
        <lightning:layoutItem padding="around-small" size="6">
            <!-- CREATE NEW Item -->
            <div aria-labelledby="newCampaingform">
                <!-- BOXED AREA -->
                <fieldset class="slds-box slds-theme--default slds-container--small">
                    <legend id="newCampaingform" class="slds-text-heading--small 
                      slds-p-vertical--medium">
                      Add Expense
                    </legend>
                    
                    <!-- CREATE NEW EXPENSE FORM -->
                    <form class="slds-form--stacked">
                         <!-- For Name Field -->
        <lightning:input aura:id="expenseform" label="Camping Name"
                         name="expensename"
                         value="{!v.newItem.Name}"
                         required="true"/>
        <!-- For Quantity Field -->
        <lightning:input type="number" aura:id="campingform" label="Quantity"
                         name="expenseamount"
                         min="1"
                         value="{!v.newItem.Quantity__c}"
                         messageWhenRangeUnderflow="Enter minimum 1 Quantity"/>
         <!-- For Price Field -->
        <lightning:input aura:id="campingform" label="Price"
                         formatter="currency"
                         name="expenseclient"
                         value="{!v.newItem.Price__c}"
                          />
         <!-- For Check Box -->
        <lightning:input type="checkbox" aura:id="campingform" label="Packed"  
                         name="expreimbursed"
                         checked="{!v.newItem.Packed__c}"/>
        
        <lightning:button label="Create Camping" 
                          class="slds-m-top--medium"
                          variant="brand"
                          onclick="{!c.createItem}"/>
                    </form>
                </fieldset>
            </div>
        </lightning:layoutItem>
    </lightning:layout>
    <!-- ITERATIING ITEM LISTS -->
    <div class="slds-card slds-p-top--medium">
        
        <c:campingHeader />
        
        <section class="slds-card__body">
            <div id="list" class="row">
                <aura:iteration items="{!v.items}" var="item">
                    <c:campingListItem item="{!item}"/>
                </aura:iteration>
            </div>
        </section>
    </div>    
    <!-- / ITERATIING ITEM LISTS -->
</aura:component>


CampingListController.js
({     
      doInit: function(component, event, helper) {
        
        // Create the action
        var action = component.get("c.getItems");
        
        // Add callback behavior for when response is received
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                component.set("v.items", response.getReturnValue());
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
        
        // Send action off to be executed
        $A.enqueueAction(action);
        },
        
    createItem: function(component, event, helper) {
        var newCamping = component.get("v.newItem");
        helper.createItem(component, newCamping);
    }
              
})


CampingListHelper.js
({
    createItem: function(component, camping) {
        
        var action = component.get("c.saveItem");
        action.setParams({
            "item": camping
        });
        action.setCallback(this, function(response){
        var state = response.getState();
        if (component.isValid() && state === "SUCCESS") {
            var campings = component.get("v.items");
            campings.push(response.getReturnValue());
            component.set("v.items", campings);
        }
        });
        $A.enqueueAction(action);
    }
})


CampingListController
public with sharing class CampingListController{

    @AuraEnabled
    public static List<Camping_Item__c> getItems(){
    
        return [Select id, name, Packed__c, Price__c, Quantity__c from Camping_Item__c];
    }
    
    @AuraEnabled
    public static Camping_Item__c saveItem(Camping_Item__c Item){
    
        upsert Item;
        return Item;
    }

}
I have the following code that get 'Apex CPU time limit exceeded'

 List<USER>  userList = new List<USER>();
  
   for (USER  aUser : [SELECT u.city, u.id FROM User  u where u.state = 'NEW YORK']  )  { 
        aUser.city = 'New York';      
        userList.add(aUser);
  }
 update  userList;
 
Per recommendations  below:

// Use this format for efficiency if you are executing DML statements // within the for loop. Be careful not to exceed the 150 DML statement limit. Account[] accts = new Account[];
for (List<Account> acct : [SELECT id, name FROM account WHERE name LIKE 'Acme']) {
  // Your logic here
accts.add(acct);
}
update accts;

, I revised the query as follows

   List<USER> userList = new List<USER>();

for (List<USER> user : [SELECT u.id FROM User u where u.state = 'NEW YORK']) {
  ...
    userList.add(user);
}
 
but get this error: 

 
Method does not exist or incorrect signature: void add(List<User>) from the type List<User>

Please tell me why. thanks a lot
HI All,

i have written the below trigger on the ContentDocument object for a Before Insert scenerio, but the trigger seems not to be firing.
Can anyone help me with this, below is my code

Trigger
trigger ContentDocumentTrigger on ContentDocument (Before Insert) {
    if(trigger.isInsert && trigger.isBefore){
        fileSharing.publicGroupOwnership1(trigger.new);
    }
}

Handler class
public without sharing class fileSharing{
    
    public static void publicGroupOwnership1 (list<ContentDocument> ContentDocumentRcd){
        
        profile adminProfile = [Select id from profile where name='System Administrator'];        
        user adminUser = [Select id, name from user where profileId=:adminProfile.id];
        
        for(ContentDocument ContentDocumentLoop :ContentDocumentRcd){
            
            ContentDocumentLoop.OwnerId = adminUser.Id;
        }
        system.debug('$$contentDocumentRcd '+contentDocumentRcd);
    }
}
HI All,
i need some help
i am stuck at there part where i am not able to save the data from the page to the database, and the strange part is, that with my below code i am able to clear the challange
below is my code 

CampingList.cmp
<aura:component controller="CampingListController">
    
    <aura:attribute name="items" type="Camping_Item__c[]"/>
    <aura:attribute name="newItem" type="Camping_Item__c" default="{'Name':'',
                                                                   'Quantity__c':0,
                                                                   'Price__c':0,
                                                                   'Packed__c':false,
                                                                   'sobjectType':'Camping_Item__c'}"/>
  <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    
    <c:campingHeader />
    
    <!-- NEW Item entry FORM -->
    <lightning:layout >
        <lightning:layoutItem padding="around-small" size="6">
            <!-- CREATE NEW Item -->
            <div aria-labelledby="newCampaingform">
                <!-- BOXED AREA -->
                <fieldset class="slds-box slds-theme--default slds-container--small">
                    <legend id="newCampaingform" class="slds-text-heading--small 
                      slds-p-vertical--medium">
                      Add Expense
                    </legend>
                    
                    <!-- CREATE NEW EXPENSE FORM -->
                    <form class="slds-form--stacked">
                         <!-- For Name Field -->
        <lightning:input aura:id="expenseform" label="Camping Name"
                         name="expensename"
                         value="{!v.newItem.Name}"
                         required="true"/>
        <!-- For Quantity Field -->
        <lightning:input type="number" aura:id="campingform" label="Quantity"
                         name="expenseamount"
                         min="1"
                         value="{!v.newItem.Quantity__c}"
                         messageWhenRangeUnderflow="Enter minimum 1 Quantity"/>
         <!-- For Price Field -->
        <lightning:input aura:id="campingform" label="Price"
                         formatter="currency"
                         name="expenseclient"
                         value="{!v.newItem.Price__c}"
                          />
         <!-- For Check Box -->
        <lightning:input type="checkbox" aura:id="campingform" label="Packed"  
                         name="expreimbursed"
                         checked="{!v.newItem.Packed__c}"/>
        
        <lightning:button label="Create Camping" 
                          class="slds-m-top--medium"
                          variant="brand"
                          onclick="{!c.createItem}"/>
                    </form>
                </fieldset>
            </div>
        </lightning:layoutItem>
    </lightning:layout>
    <!-- ITERATIING ITEM LISTS -->
    <div class="slds-card slds-p-top--medium">
        
        <c:campingHeader />
        
        <section class="slds-card__body">
            <div id="list" class="row">
                <aura:iteration items="{!v.items}" var="item">
                    <c:campingListItem item="{!item}"/>
                </aura:iteration>
            </div>
        </section>
    </div>    
    <!-- / ITERATIING ITEM LISTS -->
</aura:component>


CampingListController.js
({     
      doInit: function(component, event, helper) {
        
        // Create the action
        var action = component.get("c.getItems");
        
        // Add callback behavior for when response is received
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                component.set("v.items", response.getReturnValue());
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
        
        // Send action off to be executed
        $A.enqueueAction(action);
        },
        
    createItem: function(component, event, helper) {
        var newCamping = component.get("v.newItem");
        helper.createItem(component, newCamping);
    }
              
})


CampingListHelper.js
({
    createItem: function(component, camping) {
        
        var action = component.get("c.saveItem");
        action.setParams({
            "item": camping
        });
        action.setCallback(this, function(response){
        var state = response.getState();
        if (component.isValid() && state === "SUCCESS") {
            var campings = component.get("v.items");
            campings.push(response.getReturnValue());
            component.set("v.items", campings);
        }
        });
        $A.enqueueAction(action);
    }
})


CampingListController
public with sharing class CampingListController{

    @AuraEnabled
    public static List<Camping_Item__c> getItems(){
    
        return [Select id, name, Packed__c, Price__c, Quantity__c from Camping_Item__c];
    }
    
    @AuraEnabled
    public static Camping_Item__c saveItem(Camping_Item__c Item){
    
        upsert Item;
        return Item;
    }

}