diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js index dbc7b52a7f09de97eac4cea6c1b8f78f66c90e3f..1865636aa46892fa6060278600c59c715d97a9fd 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js @@ -27,11 +27,22 @@ function SampleTableView(sampleTableController, sampleTableModel) { if(this._sampleTableModel.experimentIdentifier) { var experimentCode = this._sampleTableModel.experimentIdentifier.split("/")[3]; - var sampleTypeCode = experimentCode.substring(0,experimentCode.indexOf("_COLLECTION")); + var allSampleTypes = profile.getAllSampleTypes(); + var sampleTypeCodesFound = []; + for(var aIdx = 0; aIdx < allSampleTypes.length; aIdx++) { + var auxSampleTypeCode = allSampleTypes[aIdx].code; + if(experimentCode.indexOf(auxSampleTypeCode) !== -1) { + sampleTypeCodesFound.push(auxSampleTypeCode); + } + } + + var sampleTypeCode = null; + if(sampleTypeCodesFound.length === 1) { + sampleTypeCode = sampleTypeCodesFound[0]; + } //Add Sample Type - if(profile.getSampleTypeForSampleTypeCode(sampleTypeCode) && - !profile.isSampleTypeHidden(sampleTypeCode)) { + if(sampleTypeCode !== null && !profile.isSampleTypeHidden(sampleTypeCode)) { $title.append(" "); $title.append(FormUtil.getButtonWithText("Create " + sampleTypeCode, function() {