RE: Defaulting look up field after filtering the lookup view
You can use the Xrm.Page.getAttribute(lookupName).setValue() to set the value of the lookup.
You will need to know the Guid, Name and entityName of the record that you want to set as default.
You can use the following helper function to set the default value:
// fieldname = The name of the lookup attribute on the entity form
// lookupId = the unique identifier (Guid), of the lookup record you want to set as default
// lookupName = The display name of the lookup record you want to set as default. For example if the lookup is to the account record, this would be the value of the name field of the account record
// entity name = The name of the entity the lookup references. Such as account.
function setLookupField(fieldName, lookupId, lookupName, entityName) {
var lookupData = new Array();
var lookupItem = new Object();
lookupItem.id = lookupId;
lookupItem.name = lookupName;
lookupItem.entityType = entityName;
lookupData[0] = lookupItem;
Xrm.Page.getAttribute(fieldName).setValue(lookupData);
}
Hope this helps.