function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Heather_HansonHeather_Hanson 

Convert Products to Assets with Record Types

We use the "Convert Products to Assets" app from app exchange.  I have emailed them, but got no response so wondering if anyone can help me with my problem.  I have found no other cases where people were trying to do what I'm trying to do and I'm having trouble getting it to work.

We recently decided we need 2 record types for our Assets so when we use the convert products to assets, we need the Visualforce page to include the option to indicate the correct Record Type.  It should be fairly easy since the page is already built so copy and paste the code, put the correct field value and voila, but record type is a special kind of field so it is not working.  I tried RecordType.Id too to see if that would work, but no luck....any suggestions would be appreciated!! 

Sample code below and I included what I tried for the Record Type ID. 
<apex:column >
            <apex:facet name="header">
              <div class="slds-text-title_caps">{!$ObjectType.Asset.Fields.SerialNumber.Label}</div>
            </apex:facet>
            <apex:inputField value="{!val.asset.SerialNumber}" styleClass="{!IF(val.asset.Quantity > 0,'','field-disabled')}"/>
          </apex:column>
          <apex:column headerValue="Record Type">
            <apex:facet name="header">
              <div class="slds-text-title_caps">{!$ObjectType.Asset.Fields.RecordType.Id.Label}</div>
            </apex:facet>
            <apex:inputField value="{!val.asset.RecordType.Id}" styleClass="{!IF(val.asset.Quantity > 0,'','field-disabled')}"/>
          </apex:column>

 
Best Answer chosen by Heather_Hanson
Heather_HansonHeather_Hanson
What I ended up doing was creating a regular picklist field which I could add to the convert products to assets code, then using process builder I said take the value of that field and set the layout to the corresponding record ID whenever the record is created.

Thanks for your help!

All Answers

Tuan LuTuan Lu
Try value="{!val.asset.RecordType}" without the .Id.
Heather_HansonHeather_Hanson
Sorry, should have mentioned that i already tried that.  I just tried it again and it doesn't work.  The error message I get for both is:

Unknown property '$ObjectType.Asset.fields.RecordType.'
 
Tuan LuTuan Lu
I just looked in my org, RecordType is not a field on Asset. Really weird as its a standard object. You might have to take this one to the support gods..
Heather_HansonHeather_Hanson
I was able to create record types in the Asset and when you do it appears on the standard fields...

User-added image
Tuan LuTuan Lu
Sorry Heather about going down rabbit hole with the RecordType.Id thing. You can not use InputField for record types like that. You will need to use a select/option control to create a picklist. You will also have to link it to a server side controller to query and return RecordType objects where SobjectType = your object. Here are some links that may help you.

https://salesforce.stackexchange.com/questions/18153/how-to-select-both-record-type-and-picklist-in-a-vf-page
Heather_HansonHeather_Hanson
What I ended up doing was creating a regular picklist field which I could add to the convert products to assets code, then using process builder I said take the value of that field and set the layout to the corresponding record ID whenever the record is created.

Thanks for your help!
This was selected as the best answer