3

Background

I've overridden the new button for a custom object with a skuid page. When the new button for custom object is clicked from a parent object, I'd like the parent lookup to be populated. For example, if new Contact is clicked from an Account I'd want the account to be defaulted. Is there any native features on skuid for this?

What I've tried

Currently I'm trying to parse the lookup ids, e.g. CF00N123123123123_lkid, and use that to default my model, but this is becoming quite involved to get the id and name properly decoded and in the right place. It feels like there should be a simpler solution for this, but I haven't been able to locate in the skuid docs (I'm very new to this, and likely am just not searching for the correct terms).

3

In general, the approach is to add URL Parameter Conditions to your Model on the Lookup/Master-Detail field in question, as these Conditions will be applied as default values when creating new records in this Model. The specific URL Parameter(s) that you need to listen for depends on your initial entry point(s) into your overridden Skuid page.

If the initial entry point into the "New" action is from a standard "New" button from a standard related list, e.g. the standard "New" button on the Contacts related list on a standard Salesforce Account detail page, then you'll have to add URL Parameter Conditions on your Skuid Model on the CF__ parameters, e.g. if you have overridden the New Contact action with a Skuid Page, and CF00N123123123123_lkid is the URL Parameter containing the source Account's Id, then your Condition on your new Contact Model would be:

  • Field: AccountId
  • Operator: =
  • Value: { Content: URL Parameter, Parameter Name: CF00N123123123123_lkid, If this Parameter is not provided, then: Deactivate this Condition }

enter image description here

If the initial entry point is from a Skuid Page, however, then you can choose an arbitrary URL Parameter to expect to be passed to your Condition, e.g. accountid, and then you just have to make sure that all relevant entry points provide a value for that URL Parameter. So your Condition would look like:

  • Field: AccountId
  • Operator: =
  • Value: { Content: URL Parameter, Parameter Name: accountid, If this Parameter is not provided, then: Deactivate this Condition }

enter image description here

The benefit of the "Deactivate this Condition" property is that, if you include both of these Conditions on your NewContact Model, then the Model will take whichever of these is actually provided, and if none is provided, you can allow your users to pick an Account, rather than having one provided by default.

And supposing that you had a "New Contact" button on a Skuid Contacts table, on a Skuid Account detail page, if you want this button to take you to your separate Skuid Page for creating a New Contact (rather than adding the new Contact inline in the table), and you want the context Account's Id to be passed along, then your Button should be of type "URL Redirect" and pass the Account's Id in the URL, through a syntax something like this:

/{{Model.keyPrefix}}/e?accountid={{$Model.Account.data.0.Id}}

which at runtime would be translated into something like:

/003/e?accountid=001000000000123ABC

If you're not showing the AccountId field in a Table/Field Editor on your "New Contact" Skuid Page, then this is all you need to do --- when you click Save, the new Contact will be saved with its AccountId set to whatever value was passed in via whichever URL Parameter was passed in.

But if you want to have the AccountId field show up in your page, then there's another two Conditions you might want to add. In order for Skuid to show the correct Name field value, e.g. "United Oil and Gas", for any lookups whose Ids you passed in via URL Parameters, you can pass in the Name field value via a separate URL Parameter, which Skuid will use as long as the Lookup Id field (e.g. AccountId) is also populated) e.g.

 Field: Account.Name
 Operator: =
 Value: { Content: URL Parameter, Parameter Name: "accountname", If this Parameter is not provided, then: Deactivate this Condition }

So if your Skuid Page is called "NewContact" and the URL looks something like this:

https://skuid.na11.visual.force.com/apex/skuid__ui?page=NewContact&accountid=001G000000qI8RFIA0&accountname=United%20Oil%20%26%20Gas%2C%20UK

Then your page would look like:

enter image description here

  • Would this work for non-Id fields, say CloseDate on the opportunity? – Sam Kamensky Jul 28 '16 at 22:17
  • @SamKamensky Yes you can pass in default values for any field type, including Dates, e.g. ?page=NewOpportunity&closedate=2016-06-30 – zachelrath Jul 29 '16 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.