• Toby Tarczy
  • NEWBIE
  • 32 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 8
    Replies
Hi,

I have created a new object called Factory with a field called Factory.name. I would now like to update all the Order records as I have added a lookup field from Order to the Factory Object to add the Factory.name on the order. The filter would be based on the customer name where I would like to run the update script for each customer separately. The upate would be all orders with the name of "Account Name to be added" , (preference would be to include multiple account names), and the Factory Name would = "Wolverhampton". I am not very well versed with DML or SFCD sql , however if someone could kindly provide the statement structure I would be very gratelful.

Many thanks

Toby
Hi 

I have gone to great lengths to create a S-Doc file using HTML. The output file requires a cell to change colour based on the value of the object field. so I have created the following which works when i test it on a web browser html screen. The script I run to dynamically change the colour of the cell utlises a src file which does not work when I use it in SFDC.  Here is the partial code that I have put together and I have bolded the areas that I think are causing me problems. Is there a way that I can host the src file in SFDC? Or is there a way that I can run a script that will execute the process whereby the value returned in the one cell changes the background colour of the cell? Many thanks in advance.

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js"></script><script type="text/javascript">


$(document).ready(function(){
    $('#table_id td.colour').each(function(){
        if ($(this).text() == 'Medical Green') {
            $(this).css('background-color','#66ffcc');}
        
        else if ($(this).text() == 'Medical Blue') {
            $(this).css('background-color','#0099ff');}
        
        else if ($(this).text() == 'Light Blue') {
            $(this).css('background-color','#99ccff');}
        
        else if ($(this).text() == 'White') {
            $(this).css('background-color','#ffffff');}
        
        else if ($(this).text() == 'Lilac') {
            $(this).css('background-color','#ccccff');}
        
        else if ($(this).text() == 'Cream') {
            $(this).css('background-color','#ffffe6');}
        
        else if ($(this).text() == 'Grey') {
            $(this).css('background-color','#cccccc');
        }
    });
});



</script>
<style media="all" type="text/css">@page {
            size: A4 portrait; 
            margin-top: 1.25in;
            margin-left: 0.5in;
            margin-right: 0.5in;
            margin-bottom: 1.25in;
            border: none;
            padding: 0em;    

         @top-left{
                content: element(header);        
         }
         @bottom-center{
                content: element(footer);
            }
}

        #page-header {
            position: running(header);
            top: 0px;
            left: 0px;
            width: 100%;
            font-family: verdana,geneva,sans-serif;
            padding: 10px;
                padding-bottom: 75px;
            padding-top: 0px;
            display: table;
        }
        
        #page-footer {
            position: running(footer);
            display: block; 
        }



          td.special { border: 2px double; }
</style>
<div id="page-header">
<table style="border-bottom-color:rgb(0, 0, 0);border-bottom-style:solid;border-bottom-width:0pt;color:rgb(169, 169, 169);font-family:verdana,geneva,sans-serif;font-size:36pt;height:9px;vertical-align:bottom;" width="100%">
    <tbody>
        <tr>
            <td style="vertical-align: top; width: 40%; text-align: center;"><span style="font-family:verdana,geneva,sans-serif;"><img alt="" src="/servlet/servlet.ImageServer?id=015240000006wpkAAA&amp;oid=00D24000000diL5EAI" style="width: 267px; height: 82px;" /></span></td>
        </tr>
    </tbody>
</table>
</div>

<div style="text-align: center;"><span style="font-size:20px;"><span style="color:#000000;"><span style="font-family: verdana, geneva, sans-serif; line-height: 20.8px; text-align: right;">WORK ORDER INSTRUCTIONS&nbsp;</span></span></span><br />
<br />
<span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;"><strong>MANUFACTURE DATE:<br />
{{!Factory_Order_Item__c.factory_start_time__c dd/MM/yyyy}}</strong></span></span><br />
&nbsp;
<table align="center" border="0" cellpadding="8" cellspacing="8" id="table_id" style="height:200px;width:650px;">
    <tbody>
        <tr>
            <td style="text-align: left; width: 300px; vertical-align: middle;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:16px;">P/O NUMBER</span></span></td>
            <td class="special" style="text-align: center; vertical-align: middle; width: 350px;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:16px;"><strong>{{!Factory_Order_Item__c.Factory_Order__r.Order__r.orderreferencenumber}}</strong></span></span></td>
        </tr>
        <tr>
            <td style="text-align: left; width: 300px; vertical-align: middle;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:16px;">CUSTOMER</span></span></td>
            <td class="special" style="text-align: center; vertical-align: middle; width: 350px;"><span style="font-family:arial,helvetica,sans-serif;"><strong><span style="font-size:16px;">{{!Factory_Order_Item__c.customer_name__c}}</span></strong></span></td>
        </tr>
        <tr>
            <td style="text-align: left; width: 300px; vertical-align: middle;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:16px;">COLOUR</span></span></td>
            <td class="colour" style="text-align: center; vertical-align: middle; width: 350px;"><span style="font-family:arial,helvetica,sans-serif;"><strong><span style="font-size:16px;">Medical Green</span></strong></span></td>
        </tr>
I have had some help in creating a trigger to populate the Name field of a customer object, Work_Request_Resource_c, Now I am trying to create a test class for the trigger and this is what I have come up with:

Trigger:

trigger WorkResourceTrigger on Work_Request_Resource__c( before insert, before update )
{
    Set<Id> contactIds = new Set<Id>();
    for( Work_Request_Resource__c res : trigger.new )
    {
        if( res.Contact__c != null )
        {
            contactIds.add( res.Contact__c );
        }
    }
    
    Map<Id, Contact> contactMap = new Map<Id, Contact>([ Select Id, Name from Contact where Id IN :contactIds ]);
    
    for( Work_Request_Resource__c res : trigger.new )
    {
        if( res.Contact__c != null )
        {
            res.Name = contactMap.get( res.Contact__c ).Name;
        }
    }
}

Test Class

@IsTest
public class WorkRequestResource {

    static testmethod void insertWork_Request_Resource_c(){
    
    Work_Request_Resource__c r = new Work_Request_Resource__c();
    
  
    r.name = 'Temp';
    
    //Get list of Accounts
    
    r.supplier__c = 'DCCL';
    r.contact__c = 'Julian, Rogers';
    
    insert r;
    
    }
    }

I am not sure how to test the  2 lookup fields, Supplier - Accounts which have been filtered on Type, to be "Supplier", and Resource.Name__c looking up the Contacts from the selected Supplier.

I have been trying to find some sample code on Google but I have not been able to get pass this point. many thanks in advance
Hi

I am new to process builder, and with some help I managed to create 2 processes. 

I have a process whereby i would like to populate the primary filed of an object to be equal to the lookup value of contacts from an account. Here is the structure:

Object - Work Request Resource
Case if Work_Request_Resource.Contact__c is not blank 

Action - update and edit Work_Request_Resource.Resource_Name_cc to equal Work_Request_Resource.Contact__c

I was also thinking of a trigger but I can't get the trigger to update the primary field. 

The reason why I am taking this round about way is so that I can see the Contact Name on lookup lists, and  not just an ID

My preference would be to use Process Builder, however I am open to triggers

Many thanks in advance 
Hi,

I have created a new object called Factory with a field called Factory.name. I would now like to update all the Order records as I have added a lookup field from Order to the Factory Object to add the Factory.name on the order. The filter would be based on the customer name where I would like to run the update script for each customer separately. The upate would be all orders with the name of "Account Name to be added" , (preference would be to include multiple account names), and the Factory Name would = "Wolverhampton". I am not very well versed with DML or SFCD sql , however if someone could kindly provide the statement structure I would be very gratelful.

Many thanks

Toby
Hi 

I have gone to great lengths to create a S-Doc file using HTML. The output file requires a cell to change colour based on the value of the object field. so I have created the following which works when i test it on a web browser html screen. The script I run to dynamically change the colour of the cell utlises a src file which does not work when I use it in SFDC.  Here is the partial code that I have put together and I have bolded the areas that I think are causing me problems. Is there a way that I can host the src file in SFDC? Or is there a way that I can run a script that will execute the process whereby the value returned in the one cell changes the background colour of the cell? Many thanks in advance.

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js"></script><script type="text/javascript">


$(document).ready(function(){
    $('#table_id td.colour').each(function(){
        if ($(this).text() == 'Medical Green') {
            $(this).css('background-color','#66ffcc');}
        
        else if ($(this).text() == 'Medical Blue') {
            $(this).css('background-color','#0099ff');}
        
        else if ($(this).text() == 'Light Blue') {
            $(this).css('background-color','#99ccff');}
        
        else if ($(this).text() == 'White') {
            $(this).css('background-color','#ffffff');}
        
        else if ($(this).text() == 'Lilac') {
            $(this).css('background-color','#ccccff');}
        
        else if ($(this).text() == 'Cream') {
            $(this).css('background-color','#ffffe6');}
        
        else if ($(this).text() == 'Grey') {
            $(this).css('background-color','#cccccc');
        }
    });
});



</script>
<style media="all" type="text/css">@page {
            size: A4 portrait; 
            margin-top: 1.25in;
            margin-left: 0.5in;
            margin-right: 0.5in;
            margin-bottom: 1.25in;
            border: none;
            padding: 0em;    

         @top-left{
                content: element(header);        
         }
         @bottom-center{
                content: element(footer);
            }
}

        #page-header {
            position: running(header);
            top: 0px;
            left: 0px;
            width: 100%;
            font-family: verdana,geneva,sans-serif;
            padding: 10px;
                padding-bottom: 75px;
            padding-top: 0px;
            display: table;
        }
        
        #page-footer {
            position: running(footer);
            display: block; 
        }



          td.special { border: 2px double; }
</style>
<div id="page-header">
<table style="border-bottom-color:rgb(0, 0, 0);border-bottom-style:solid;border-bottom-width:0pt;color:rgb(169, 169, 169);font-family:verdana,geneva,sans-serif;font-size:36pt;height:9px;vertical-align:bottom;" width="100%">
    <tbody>
        <tr>
            <td style="vertical-align: top; width: 40%; text-align: center;"><span style="font-family:verdana,geneva,sans-serif;"><img alt="" src="/servlet/servlet.ImageServer?id=015240000006wpkAAA&amp;oid=00D24000000diL5EAI" style="width: 267px; height: 82px;" /></span></td>
        </tr>
    </tbody>
</table>
</div>

<div style="text-align: center;"><span style="font-size:20px;"><span style="color:#000000;"><span style="font-family: verdana, geneva, sans-serif; line-height: 20.8px; text-align: right;">WORK ORDER INSTRUCTIONS&nbsp;</span></span></span><br />
<br />
<span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;"><strong>MANUFACTURE DATE:<br />
{{!Factory_Order_Item__c.factory_start_time__c dd/MM/yyyy}}</strong></span></span><br />
&nbsp;
<table align="center" border="0" cellpadding="8" cellspacing="8" id="table_id" style="height:200px;width:650px;">
    <tbody>
        <tr>
            <td style="text-align: left; width: 300px; vertical-align: middle;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:16px;">P/O NUMBER</span></span></td>
            <td class="special" style="text-align: center; vertical-align: middle; width: 350px;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:16px;"><strong>{{!Factory_Order_Item__c.Factory_Order__r.Order__r.orderreferencenumber}}</strong></span></span></td>
        </tr>
        <tr>
            <td style="text-align: left; width: 300px; vertical-align: middle;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:16px;">CUSTOMER</span></span></td>
            <td class="special" style="text-align: center; vertical-align: middle; width: 350px;"><span style="font-family:arial,helvetica,sans-serif;"><strong><span style="font-size:16px;">{{!Factory_Order_Item__c.customer_name__c}}</span></strong></span></td>
        </tr>
        <tr>
            <td style="text-align: left; width: 300px; vertical-align: middle;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:16px;">COLOUR</span></span></td>
            <td class="colour" style="text-align: center; vertical-align: middle; width: 350px;"><span style="font-family:arial,helvetica,sans-serif;"><strong><span style="font-size:16px;">Medical Green</span></strong></span></td>
        </tr>
I have had some help in creating a trigger to populate the Name field of a customer object, Work_Request_Resource_c, Now I am trying to create a test class for the trigger and this is what I have come up with:

Trigger:

trigger WorkResourceTrigger on Work_Request_Resource__c( before insert, before update )
{
    Set<Id> contactIds = new Set<Id>();
    for( Work_Request_Resource__c res : trigger.new )
    {
        if( res.Contact__c != null )
        {
            contactIds.add( res.Contact__c );
        }
    }
    
    Map<Id, Contact> contactMap = new Map<Id, Contact>([ Select Id, Name from Contact where Id IN :contactIds ]);
    
    for( Work_Request_Resource__c res : trigger.new )
    {
        if( res.Contact__c != null )
        {
            res.Name = contactMap.get( res.Contact__c ).Name;
        }
    }
}

Test Class

@IsTest
public class WorkRequestResource {

    static testmethod void insertWork_Request_Resource_c(){
    
    Work_Request_Resource__c r = new Work_Request_Resource__c();
    
  
    r.name = 'Temp';
    
    //Get list of Accounts
    
    r.supplier__c = 'DCCL';
    r.contact__c = 'Julian, Rogers';
    
    insert r;
    
    }
    }

I am not sure how to test the  2 lookup fields, Supplier - Accounts which have been filtered on Type, to be "Supplier", and Resource.Name__c looking up the Contacts from the selected Supplier.

I have been trying to find some sample code on Google but I have not been able to get pass this point. many thanks in advance
Hi

I am new to process builder, and with some help I managed to create 2 processes. 

I have a process whereby i would like to populate the primary filed of an object to be equal to the lookup value of contacts from an account. Here is the structure:

Object - Work Request Resource
Case if Work_Request_Resource.Contact__c is not blank 

Action - update and edit Work_Request_Resource.Resource_Name_cc to equal Work_Request_Resource.Contact__c

I was also thinking of a trigger but I can't get the trigger to update the primary field. 

The reason why I am taking this round about way is so that I can see the Contact Name on lookup lists, and  not just an ID

My preference would be to use Process Builder, however I am open to triggers

Many thanks in advance